springboot2集成prometheus并配置grafana图表
pom.xml
1 | <dependency> |
application.properties
1 | management.endpoints.web.exposure.include=* |
Controller
1 | import org.springframework.beans.factory.annotation.Value; |
springboot2启用/actuator/prometheus端点,供Prometheus来抓取指标。
1 | /actuator/prometheus |
配置grafana曲线
grafana模板:https://grafana.com/dashboards/4701
在Grafana内点击如图所示import按钮,在如图所示位置填写4701,然后点击load。
源码
https://gitee.com/dalaoyang/springboot_learn/tree/master/springboot2_prometheus
https://github.com/vacual/spring-boot-examples/tree/master/spring-boot-micrometer-vacual
启动程序
1 | ps -ef|grep java | grep -v grep |
prometheus配置
1 |
|