在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 的数据源
到这基本配置结束
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器