恒美微站 Logo 恒美微站
  • 首页
  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心
  • 联系我们

【运维监控】Prometheus+grafana监控spring boot 3运行情况

  • 首页
  • 资讯中心
  • /
  • 【运维监控】Prometheus+grafana监控spring boot 3运行情况

相关资讯

客房部绩效考核管理制度与绩效提升策略 2026/9/26 15:37:39
BK7238单芯片双模架构:Wi-Fi与BLE硬件级共生设计 2026/9/26 15:37:39
Obsidian + Claude Code + 微信AI 三系统缝合:TaoToken 统一 Key 配置与联调验证 2026/9/26 15:37:39

最新资讯

AI 开发工具提示词大揭秘:Cursor、Cline、Windsurf 核心逻辑全公开!TaoToken 统一 Key 配置实战
工厂方法模式:把创建延迟到子类
Vibe Coding 小白上手指南:用 TaoToken 统一 Key 跑通 React+TypeScript 提示词工作流
Windows 上装官方 Claude Code 总报错?TaoToken 配置骨架与验证清单
MCP 从概念到实战:用 TaoToken 统一 Key 打通 AI Agent 工具链
长任务压缩不该失忆:Coding Agent 上下文工程实战——用 TaoToken 统一 Key 打通 Cline 配置

今日推荐

麒麟Kylin V10 SP3服务器安装实战:硬件兼容、启动优化与生产级分区
华为手机助手导致Windows内存完整性关闭的根因与修复
图书馆图书借阅管理系统:JSP+Servlet+MySQL源码部署与答辩指南

本周热门

BrewUI:给Homebrew套上图形界面,让macOS软件包管理更简单
BrewUI:让Homebrew包管理变得可视化与高效
公式与文本对齐全攻略:从Word到LaTeX的实用技巧

本月精选

自研推理加速器Redwood:两周内实现PyTorch模型高效部署的实战教程
V4L2摄像头采集实战:从camera_client.rar到出图全流程解析
从“谁发明了钢琴键”到知识问答智能体:RAG与记忆工程实践

【运维监控】Prometheus+grafana监控spring boot 3运行情况

发布时间:2026/9/26 15:37:39
【运维监控】Prometheus+grafana监控spring boot 3运行情况 运维监控系列文章入口【运维监控】系列文章汇总索引最近在研究 AI BI智能数据分析 的落地实践。敬请期待后续专题实战系列《从零手把手教你搭建 AI 驱动的 BI 系统》将覆盖 Text2SQL、多轮对话、语义层、权限治理、生产级部署全链路代码可落地、坑点全复盘。文章目录一、prometheus二、grafana三、创建java应用及配置1、pom.xml2、application.properties3、java 类4、验证四、grafana集成prometheus监控springboot应用1、修改prometheus配置及重启2、导入grafana模板3、验证本示例通过spring boot自带的监控信息暴露出来然后将数据收集到prometheus中最后通过grafana的dashboard导入模板进行可视化。本示例分为四个部分即prometheus、grafana部署、springboot示例和最后的集成。说明本示例中的部署环境没有要求即应用部署的机器根据实际情况而定只要网络连通即可。关于java应用的监控本系列有文章如下【运维监控】influxdb 2.0telegraf 监控tomcat 8.5运行情况【运维监控】influxdb 2.0grafana 监控java 虚拟机以及方法耗时情况【运维监控】Prometheusgrafana监控tomcat运行情况【运维监控】Prometheusgrafana监控spring boot 3运行情况一、prometheus参考【运维监控】prometheusnode exportergrafana 监控linux机器运行情况关于prometheus的部署。二、grafana参考【运维监控】prometheusnode exportergrafana 监控linux机器运行情况 关于grafana的部署。三、创建java应用及配置本处使用的是一个简单spring boot 3的应用对外开启2个restful接口同时引入prometheus的包。1、pom.xml仅列出引入的版本、必须的依赖和编译器根据你自己的环境而定。propertiesmaven.compiler.source17/maven.compiler.sourcemaven.compiler.target17/maven.compiler.targetproject.build.sourceEncodingUTF-8/project.build.sourceEncoding/propertiesparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.0.0/version/parentdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdscopeprovided/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependencydependencygroupIdio.micrometer/groupIdartifactIdmicrometer-registry-prometheus/artifactIdversion1.12.5/version/dependency/dependencies2、application.properties仅列出和本示例有关的内容其他忽略或默认。management.endpoints.web.exposure.include* management.endpoint.prometheus.enabledtrue3、java 类App.javapackagecom.win;importorg.springframework.boot.SpringApplication;importorg.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplicationpublicclassApp{//url/abc.jsonpublicstaticvoidmain(String[]args){SpringApplication.run(App.class,args);}}TestController.javapackagecom.win.test;importlombok.extern.slf4j.Slf4j;importorg.springframework.web.bind.annotation.*;importjava.sql.Date;importjava.text.SimpleDateFormat;Slf4jRestControllerRequestMapping(/test)CrossOriginpublicclassTestController{SimpleDateFormatdateFormatnewSimpleDateFormat(yyyy-MM-dd HH:mm:ss-SSSS);// http://localhost:8080/test/example// http://localhost:8080/test/example?messagetestGetMapping(/example)publicStringcompletion(RequestParam(valuemessage,defaultValue讲个笑话)Stringmessage){try{Thread.sleep(100);}catch(InterruptedExceptione){thrownewRuntimeException(e);}log.info(当前时间{},方法名称{},dateFormat.format(newDate(System.currentTimeMillis())),newObject(){}.getClass().getEnclosingMethod().getName());returnmessage;}// http://localhost:8080/test/example/test.json?messagetestGetMapping(/example/test.json)publicStringcompletion2(RequestParam(valuemessage,defaultValue讲个笑话)Stringmessage){try{Thread.sleep(100);}catch(InterruptedExceptione){thrownewRuntimeException(e);}log.info(当前时间{},方法名称{},dateFormat.format(newDate(System.currentTimeMillis())),newObject(){}.getClass().getEnclosingMethod().getName());returnmessage;}}4、验证启动应用查看http://localhost:8080/actuator/prometheus链接是否可获取到相关监控的信息即可。出现如下图即表示完成。四、grafana集成prometheus监控springboot应用1、修改prometheus配置及重启在prometheus的配置文件prometheus.yml中添加如下配置部分- job_name:springboot_node_3.105metrics_path:/actuator/prometheus# metrics_path defaults to /metrics# scheme defaults to http.static_configs: - targets:[192.168.3.105:8080]重启prometheus后并验证是否收集到监控信息。查看Prometheus是否监控到运行的spring boot应用如下图。查看prometheus是否收集到监控信息如下图查询jvm_memory_max_bytes2、导入grafana模板导入过程不再赘述参考文章【运维监控】Prometheusgrafana监控tomcat8.5 运行情况本示例导入的模板ID是12900和21319。3、验证以上所涉及的服务均能正常的运行以及验证都通过。本示例为了体现有更多的数据可验证以便能更清楚的看到效果建议自己多做一点接口的调用查看运行情况否则不能直观的体现出监控的结果。以上就完成了grafana集成prometheus监控springboot应用。至此关于java应用的监控本系列有文章如下【运维监控】influxdb 2.0telegraf 监控tomcat 8.5运行情况【运维监控】influxdb 2.0grafana 监控java 虚拟机以及方法耗时情况【运维监控】Prometheusgrafana监控tomcat运行情况【运维监控】Prometheusgrafana监控spring boot 3运行情况

关于恒美微站

恒美微站专注于为个体商户、工作室提供极简自助建站服务,让每个人都能轻松拥有专业网站。

快速链接

  • 关于我们
  • 建站服务
  • 主题模板
  • 案例展示
  • 资讯中心

服务项目

  • 可视化建站
  • 拖拽编辑
  • 主题定制
  • SEO 优化
  • 网站托管

联系方式

  • 📍 地址:北京市朝阳区建国路 88 号
  • 📞 电话:400-888-8888
  • ✉️ 邮箱:info@hmyw.cn
  • 🕐 时间:周一至周日 9:00-18:00

© 2024 恒美微站 hmyw.cn 版权所有 | 京 ICP 备 12345678 号