You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.2 kB

123456789101112131415161718192021222324252627282930313233
  1. # SpringBoot
  2. Java 生态的项目,如果要暴露 metrics 数据,一般可以选择 micrometer,不过 SpringBoot 项目可以直接使用 SpringBoot Actuator 暴露 metrics 数据,Actuator 底层也是使用 micrometer 来实现的,只是使用起来更加简单。
  3. ## 应用配置
  4. 在 application.properties 中加入如下配置:
  5. ```properties
  6. management.endpoint.metrics.enabled=true
  7. management.endpoints.web.exposure.include=*
  8. management.endpoint.prometheus.enabled=true
  9. management.metrics.export.prometheus.enabled=true
  10. ```
  11. 完事启动项目,访问 `http://localhost:8080/actuator/prometheus` 即可看到符合 prometheus 协议的监控数据。
  12. ## 采集配置
  13. 既然暴露了 Prometheus 协议的监控数据,那通过 categraf prometheus 插件直接采集即可。配置文件是 `conf/input.prometheus/prometheus.toml`。配置样例如下:
  14. ```toml
  15. [[instances]]
  16. urls = [
  17. "http://192.168.11.177:8080/actuator/prometheus"
  18. ]
  19. ```
  20. ## 仪表盘
  21. 夜莺内置了一个 SpringBoot 仪表盘,由网友贡献,克隆到自己的业务组下即可使用,欢迎大家一起来提 PR 完善。
  22. ![actuator2.0](http://download.flashcat.cloud/uPic/actuator_2.0.png)