当前位置:   article > 正文

springboot 集成 actuator_springboot actuator yml

springboot actuator yml

简介

   spring-actuator做度量统计收集,使用Prometheus(普罗米修斯)进行数据收集,Grafana(增强ui)进行数据展示,用于监控生成环境机器的性能指标和业务数据指标。一般,我们叫这样的操作为”埋点”。SpringBoot中的依赖spring-actuator中集成的度量统计API使用的框架是Micrometer,官网是Micrometer.io。在实践中发现了业务开发者滥用了Micrometer的度量类型Counter,导致无论什么情况下都只使用计数统计的功能。这篇文章就是基于Micrometer分析其他的度量类型API的作用和适用场景。

1 pom 添加依赖

  1. <!--micrometer -->
  2. <dependency>
  3. <groupId>io.micrometer</groupId>
  4. <artifactId>micrometer-registry-prometheus</artifactId>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-actuator</artifactId>
  9. </dependency>

2配置文件设置

yml 类型为

  1. management:
  2. endpoints:
  3. web:
  4. exposure:
  5. include: prometheus

property类型为

management.endpoints.web.exposure.include=prometheus

3启动类添加代码

  1. @Bean
  2. MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${ruoyi.name}") String applicationName){
  3. return registry -> registry.config().commonTags("application", applicationName);
  4. }

4 访问地址 http://localhost:8088/actuator/prometheus

5注意事项

有url拦截器的,注意放开拦截器,否则 http://localhost:8088/actuator/prometheus访问失败

 filterChainDefinitionMap.put("/actuator/prometheus", "anon");

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/856552
推荐阅读
相关标签
  

闽ICP备14008679号