1.POM添加依赖包
<!--监控报警-->
<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']
basic认证示例
7.启动prometheus效果图
地址:http://localhost:9090/targets
8.下载Grafana
9.Grafana启动
地址:http://localhost:3000/
用户名admin
密码admin
10.创建
来源:oschina
链接:https://my.oschina.net/findurl/blog/4276004