springboot2配置监控prometheus

编程

      <!--监控报警-->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-actuator</artifactId>

</dependency>

<dependency>

<groupId>io.micrometer</groupId>

<artifactId>micrometer-registry-prometheus</artifactId>

</dependency>

2.添加配置

#prometheus配置 监控

management.metrics.export.prometheus.enabled=true

management.metrics.export.prometheus.step=1ms

management.metrics.export.prometheus.descriptions=true

management.endpoint.prometheus.enabled=true

management.endpoints.web.exposure.include=health,info,env,prometheus,metrics,httptrace,threaddump,heapdump,springmetric

3.配置测试

测试地址:https://localhost/actuator/prometheus

4.效果图

5.下载prometheus

6.修改配置文件 prometheus.yml

两个注意点 不然启动报错

一个是https

另一个是:后面有个空格

- job_name: "PingPangChat"   

# metrics_path defaults to "/metrics"

# scheme defaults to "http".

scheme: "https"

metrics_path: "/actuator/prometheus"

static_configs:

- targets: ["127.0.0.1"]

7.启动prometheus效果图

地址:http://localhost:9090/targets

以上是 springboot2配置监控prometheus 的全部内容, 来源链接: utcz.com/z/516374.html

回到顶部