首页 > 其他分享 >springboot开启prometheus可采集的指标配置

springboot开启prometheus可采集的指标配置

时间:2023-08-14 14:11:05浏览次数:40  
标签:springboot spring boot micrometer 开启 prometheus testService actuator

1、引包

        <!-- 实现对 Actuator 的自动化配置 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!-- Micrometer 对 Prometheus 的支持 -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>
spring-boot-starter-actuator包不需要配置版本,跟着你配置的 spring-boot版本 保持一致就好
micrometer-registry-prometheus包需要查看你项目中依赖的 spring-boot-dependencies 项目的pom文件中 micrometer.version 版本是多少,保持一致即可

例如我的springboot版本是2.6.11

 对应的 micrometer-registry-prometheus版本就是1.8.9

2、配置文件

#  endpoints config
management:
  endpoint:
    health: # 请求 http://localhost:48082/testService/actuator/health
      show-details: always
  endpoints:
    enabled-by-default: true
    web:
      base-path: /actuator
      exposure:  #请求 http://localhost:48082/testService/actuator
        include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
  metrics:
    tags: # 通用标签
      application: ${spring.application.name}  # 请求 http://localhost:48082/testService/actuator/prometheus

  请求的时候一定要带上配置

server:
  port: 48082
  servlet:
    context-path: /testService

 

标签:springboot,spring,boot,micrometer,开启,prometheus,testService,actuator
From: https://www.cnblogs.com/yuchenghao/p/17628484.html

相关文章

  • Windows服务器管理技巧:多用户登录设置、开启防火墙与SSH远程登录配置指南
    WindowsServer服务器管理技巧:对于使用WindowsServer服务器开发人员或者运维人员初学者来说,可能会遇到很多问题,比如:如何设置允许多用户同时登录服务器?如何开启服务器防火墙?Windows如何配置SSH远程登录?等等,如果遇到了这些问题,来看看这篇文章就能解决啦!一、如何设置允许多用户同时......
  • SpringBoot实现大文件上传
    ​ 对于大文件的处理,无论是用户端还是服务端,如果一次性进行读取发送、接收都是不可取,很容易导致内存问题。所以对于大文件上传,采用切块分段上传,从上传的效率来看,利用多线程并发上传能够达到最大效率。 本文是基于springboot+vue实现的文件上传,本文主要介绍服务端实现文件......
  • Prometheus
    一、Prometheus二、grafana1、添加数据模板#blackbox_exporter监控数据#每个参数是不同的dashbord模板https://grafana.com/grafana/dashboards/9965https://grafana.com/grafana/dashboards/9719 此模板需要安装饼状图插件下载地址 https://grafana.com/grafana/pl......
  • centos7 防火墙端口开启和关闭及查看
    一、防火墙的开启、关闭、禁用命令(1)设置开机启用防火墙:systemctlenablefirewalld.service(2)设置开机禁用防火墙:systemctldisablefirewalld.service(3)启动防火墙:systemctlstartfirewalld(4)关闭防火墙:systemctlstopfirewalld(5)检查防火墙状态:systemctlstatusfirewalld二......
  • 使用Spring initializr快速创建一个springboot项目
     第一步首先new一个新的project选择Springinitializr配置好相关信息后下一步编辑在左上角我们可以选择SprinBoot的版本,在这里直接加入web依赖springweb和Template的Thymeleaf依赖,点上对勾后可以在最右边里看到你选择的依赖,然后点击create编辑可以看到我们的项目结构,很多sprin......
  • 怎么给路径起别名, 并且开启代码提示
    效果:将src文件夹用@符号代替,并且在输入的时候还有提示实现:vue-cli创建的项目,在jsconfig.json文件里面{"compilerOptions":{"baseUrl":"./","paths":{"@/*":["src/*"]},}}......
  • 手摸手3-springboot整合swagger-ui,实现自动文档
    (目录)手摸手3-springboot整合swagger-ui,实现自动文档修改pom.xml<!--解决FluentIterable.class找不到问题--><dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>26.0-jre</version>......
  • springboot中tomcat线程池
    一、Tomcat中的默认配置线程任务就是一个连接的请求,每个请求都会尝试创建线程来处理。最大工作线程数,默认200。server.tomcat.max-threads=200最大连接数默认是10000,同时支持的并发连接数server.tomcat.max-connections=10000等待队列长度,默认100。server.tomcat.acce......
  • 自定义springboot-starter包
    https://www.cnblogs.com/yuansc/p/9088212.html 前言我们都知道可以使用SpringBoot快速的开发基于Spring框架的项目。由于围绕SpringBoot存在很多开箱即用的Starter依赖,使得我们在开发业务代码时能够非常方便的、不需要过多关注框架的配置,而只需要关注业务即可。例如我想......
  • springboot综合案例第四课
    day04_springboot综合案例用户管理查询用户查询所有用户执行流程编写UserMapper接口publicinterfaceUserMapper{//查询所有用户List<UserInfo>findAllUsers();}编写UserServicepublicinterfaceUserServiceextendsUserDetailsService{/**......