前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Spring Boot Actuator 整合 Prometheus

Spring Boot Actuator 整合 Prometheus

作者头像
程序员果果
发布2019-10-23 22:10:33
2.5K0
发布2019-10-23 22:10:33
举报
文章被收录于专栏:程序员果果程序员果果

简介

Spring Boot 自带监控功能 Actuator,可以帮助实现对程序内部运行情况监控,比如监控状况、Bean加载情况、环境变量、日志信息、线程信息等。这一节结合 Prometheus 、Grafana 来更加直观的展示这些信息。

实验

说明

服务名

地址

端口

Prometheus

172.16.2.101

9090

Grafana

172.16.2.101

3000

Spring Boot Demo

172.16.2.204

8080

创建项目

创建用于测试的 Spring Boot 项目,主要代码如下。

pom.xml
application.yml
  • management.endpoints.web.exposure.include:大多数actuator的端口都不会通过http公开,* 代表公开所有这些端点。对于生产环境,应该仔细选择要公开的端点。
  • management.metrics.tags.application:为应用设置 tag ,方便区分不同的应用。
启动类

配置 Prometheus 和 Grafana

在 prometheus.yml 中添加针对该 Spring Boot 应用 的监控 job

运行 Prometheus 和 Grafana:

访问 Prometheus UI http://172.16.2.101:9090 ,查看 targets ,可以看到 job 处于 UP 状态,说明配置成功了。

Grafana UI http://172.16.2.101:3000,通过Grafana的 + 图标导入(Import) JVM (Micrometer) dashboard:

  • grafana id = 4701
  • 注意选中prometheus数据源

查看JVM (Micormeter) dashboard:

可以看到应用的 JVM 的 堆栈、 线程、 IO 等等信息。

源码

https://github.com/gf-huanchupk/SpringBootLearning/tree/master/springboot-actuator-prometheus

参考

https://micrometer.io/docs/registry/prometheus https://prometheus.io/docs/prometheus

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-10-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 程序员果果 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 简介
  • 实验
    • 说明
      • 创建项目
        • pom.xml
        • application.yml
        • 启动类
      • 配置 Prometheus 和 Grafana
      • 源码
      • 参考
      相关产品与服务
      Prometheus 监控服务
      Prometheus 监控服务(TencentCloud Managed Service for Prometheus,TMP)是基于开源 Prometheus 构建的高可用、全托管的服务,与腾讯云容器服务(TKE)高度集成,兼容开源生态丰富多样的应用组件,结合腾讯云可观测平台-告警管理和 Prometheus Alertmanager 能力,为您提供免搭建的高效运维能力,减少开发及运维成本。
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档