springboot下配置prometheus


在github 上下载springboot 项目地址:

https://github.com/hgwz/jmeter-springboot-server

 

1在springboot项目中配置prometheus 的依赖

在pom.xml 文件依赖如下:

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.github.mweirauch</groupId>
<artifactId>micrometer-jvm-extras</artifactId>
<version>0.1.2</version>
</dependency>

2在application中加入如下配置
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,springmetrics

3重启下springboot项目加载配置项

4在浏览器中输入http://localhost:8089/actuator/prometheus 查看是否有对应的数据,如果有说明配置成功

 

 

 5配置prometheus 的jvm信息节点

信息如下:

- job_name: 'prometheus1'
metrics_path: '/actuator/prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

static_configs:
- targets: ['localhost:8089']

这里特别注意 metrics_path 后面的信息值必须要有空格 ,否则prometheus 启动报错

 

 

重启下prometheus

在浏览器中输入http://localhost:9090/targets
可以查看对应配置节点信息

 

 在grafana中展示prometheus 采集的数据点

启动garafana,然后在浏览器中输入localhost:3000  

输入用户名密码(admin/admin)

dashboard 直接导入9568 或者去官网查询

 

 按照条件查找到的结果9568

在garafana中配置prometheus 的数据源

 

 

 到这基本配置结束

 

  




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM