快来试试 Spring Boot 应用可视化监控,一目了然!
总阅读量:200次
摘要: 原创出处 anoyi.com/p/7ecb57a3f326 「anoyi」欢迎转载,保留摘要,谢谢!
Spring Boot 2..X 版本,可阅读如下文章:
- 芋道 Spring Boot 监控工具 Admin 入门:http://www.iocoder.cn/Spring-Boot/Admin/
- 芋道 Spring Boot 监控平台 Prometheus + Grafana 入门:http://www.iocoder.cn/Spring-Boot/Prometheus-and-Grafana/
图文简介
快速开始
1、Spring Boot 应用暴露监控指标【版本 1.5.7.RELEASE】
首先,添加依赖如下依赖:
<dependency> |
然后,在启动类 Application.java
添加如下注解:
|
最后,配置默认的登录账号和密码,在 application.yml
中:
security: |
提示:不建议配置
management.security.enabled: false
启动应用程序后,会看到如下一系列的 Mappings
利用账号密码访问 http://localhost:8080/application/prometheus ,可以看到 Prometheus 格式的指标数据
2、Prometheus 采集 Spring Boot 指标数据
首先,获取 Prometheus 的 Docker 镜像:
$ docker pull prom/prometheus |
然后,编写配置文件 prometheus.yml
:
global: |
接着,启动 Prometheus :
$ docker run -d \ |
最后,访问 http://localhost:9090/targets , 检查 Spring Boot 采集状态是否正常。
采集状态
3、Grafana 可视化监控数据
首先,获取 Grafana 的 Docker 镜像:
$ docker pull grafana/grafana |
然后,启动 Grafana:
$ docker run --name grafana -d -p 3000:3000 grafana/grafana |
接着,访问 http://localhost:3000/ 配置 Prometheus 数据源:
Grafana 登录账号 admin 密码 admin
最后,配置单个指标的可视化监控面板:
提示,此处不能任意填写,只能填已有的指标点,具体的可以在 Prometheus 的首页看到,即 http://localhost:9090/graph
多配置几个指标之后,即可有如下效果: