偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

在SpringBoot中如何通過Prometheus實(shí)時(shí)監(jiān)控系統(tǒng)各項(xiàng)指標(biāo)

數(shù)據(jù)庫 其他數(shù)據(jù)庫
prometheus存儲的是時(shí)序數(shù)據(jù),即按相同時(shí)序(相同名稱和標(biāo)簽),以時(shí)間維度存儲連續(xù)的數(shù)據(jù)的集合。

環(huán)境:springboot2.4.12 + prometheus1.6.7 + grafana7.5.7

什么是Prometheus

Prometheus 是一個(gè)開源的服務(wù)監(jiān)控系統(tǒng)和時(shí)間序列數(shù)據(jù)庫。

圖片圖片


prometheus存儲的是時(shí)序數(shù)據(jù),即按相同時(shí)序(相同名稱和標(biāo)簽),以時(shí)間維度存儲連續(xù)的數(shù)據(jù)的集合。

時(shí)序(time series)是由名字(Metric)以及一組key/value標(biāo)簽定義的,具有相同的名字以及標(biāo)簽屬于相同時(shí)序。

配置依賴

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  <dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
  </dependency>
</dependencies
spring:
  application:
    name: app-prometheus
---
management:
  server:
    port: 9999
  endpoints:
    enabled-by-default: true
    web:
      exposure:
        include: '*'

注冊MeterRegistry

@Bean
public MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String name) {
  return (registry) -> registry.config().commonTags("application", name);
}

訪問Prometheus actuator

圖片圖片

Springboot與Prometheus的整合完成。

Prometheus配置安裝

Prometheus下載

圖片圖片

通過如上地址下載自己需要的版本。

配置Prometheus

scrape_configs:
  - job_name: 'app-prometheus'
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
    - targets: ['localhost:9999']

localhost:9999為項(xiàng)目的Actuator訪問地址。

啟動Prometheus

圖片圖片

訪問

圖片圖片

查看監(jiān)控的應(yīng)用

圖片圖片

圖片圖片

自定義meter

@Resource
private MeterRegistry registry ;
private Counter counter ;
  
@PostConstruct
public void init() {
  counter = this.registry.counter("vistor") ;
}


@GetMapping("/count")
public String count() {
  this.counter.increment() ; 
  return "訪問次數(shù):" + this.counter.count() ;
}

先多訪問幾次該接口,通過Prometheus查看

圖片圖片

Grafana安裝配置

下載

圖片圖片

通過上面的地址下載grafana

啟動服務(wù)

圖片圖片

默認(rèn)用戶名密碼:admin/admin

圖片

添加Prometheus數(shù)據(jù)源

圖片圖片

查看數(shù)據(jù)

圖片圖片

圖片圖片

這里展示了visitor中的統(tǒng)計(jì)信息

監(jiān)控?cái)?shù)據(jù)庫連接池

圖片圖片

先在grafana上搜索

圖片圖片


通過id導(dǎo)入

圖片圖片


圖片圖片

圖片圖片

項(xiàng)目中配置hikari數(shù)據(jù)庫連接池,grafana自動會展示數(shù)據(jù)庫連接信息

圖片圖片

完畢!??!

責(zé)任編輯:武曉燕 來源: Spring全家桶實(shí)戰(zhàn)案例源碼
相關(guān)推薦

2023-12-29 08:01:52

自定義指標(biāo)模板

2025-07-14 05:00:00

監(jiān)控系統(tǒng)工具

2021-03-10 11:47:01

CPU服務(wù)器指標(biāo)

2022-07-08 08:00:31

Prometheus監(jiān)控

2021-03-26 20:37:14

Prometheus監(jiān)控指標(biāo)

2023-11-06 01:39:02

Go語言開發(fā)

2021-10-14 08:07:33

Go 應(yīng)用Prometheus監(jiān)控

2022-05-12 08:01:26

vmagentprometheus

2017-04-20 14:55:36

LinuxPyinotifyPython

2025-04-08 05:00:00

2025-03-11 00:25:00

Springmetrics數(shù)據(jù)

2022-03-14 08:25:49

云原生prometheusPushProx

2025-03-03 08:00:00

2023-11-16 08:00:00

Datadog部署實(shí)時(shí)監(jiān)控

2024-04-08 08:00:00

云監(jiān)控監(jiān)控?cái)?shù)據(jù)Prometheus

2024-06-14 08:19:45

2023-10-11 09:58:07

2020-12-30 08:09:46

運(yùn)維Prometheus 監(jiān)控

2021-08-30 13:08:54

Linux實(shí)時(shí)監(jiān)控日志文件

2021-04-07 14:53:09

Prometheus開源監(jiān)控
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號