actuator/prometheus使用pushgateway上传jvm监控数据

场景

准备

  1. prometheus已经部署pushgateway服务,访问{pushgateway.server:9091}可以看到面板

实现

  • 基于springboot引入支持组件,版本可以
html 复制代码
        <!--监控检查-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>1.5.14</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_pushgateway</artifactId>
            <version>0.16.0</version>
        </dependency>
  • 开启配置
bash 复制代码
management:
  endpoints:
    web:
      exposure:
        # 暴露监控接口,*为全部接口
        include: '*'
        # 不暴露接口
        # exclude: 'info'
  metrics: #是否在内存中保存监控统计数据
    export:
      simple:
        enabled: false # 关闭内存中计算指标
      prometheus:
        enabled: true # 开启prometheus上传
        pushgateway: ## 配置pushgateway信息
          enabled: true # 开启pushgateway上传
          base-url: http://10.111.11.111:9091 # 配置pushgateway服务地址
          job: ${spring.application.name} # 配置pushgateway服务地址
          grouping-key:
            instance: ${spring.application.name}:${spring.profiles.active}
            lable1: labelValue1 # 自定义tag
          push-rate: 10s #上传数据间隔

效果

在pushgateway面板中会显示新增的服务,在prometheus中也可能看到采集的数据

相关推荐
kill bert2 小时前
Java八股文背诵 第四天JVM
java·开发语言·jvm
你是理想5 小时前
wait 和notify ,notifyAll,sleep
java·开发语言·jvm
helloworld工程师5 小时前
【微服务】SpringBoot整合LangChain4j 操作AI大模型实战详解
java·eclipse·tomcat·maven
Java&Develop5 小时前
idea里面不能运行 node 命令 cmd 里面可以运行咋回事啊
java·ide·intellij-idea
q567315236 小时前
使用Java的HttpClient实现文件下载器
java·开发语言·爬虫·scrapy
你们补药再卷啦6 小时前
不用额外下载jar包,idea快速查看使用的组件源码
java·ide·intellij-idea
爱的叹息6 小时前
Spring Boot 自定义配置类(包含字符串、数字、布尔、小数、集合、映射、嵌套对象)实现步骤及示例
java·linux·spring boot
@西瓜@7 小时前
JAVAEE(多线程-线程池)
java·开发语言
returnShitBoy8 小时前
Go语言中的垃圾回收是如何工作的?
java·jvm·golang
有什么东东8 小时前
山东大学软件学院创新项目实训开发日志(9)之测试前后端连接
java