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中也可能看到采集的数据

相关推荐
程序员清风4 分钟前
专业再升级!程序员专属显示器明基RD280UG上手实测!
java·后端·面试
Lam Tang2 小时前
APS 系列文章 08
java·代理模式
萧瑟余晖2 小时前
Java深入解析篇三十三之消息队列
java·开发语言
码匠许师傅2 小时前
【C++ 面试真题】聊聊 C++ 的序列容器
java·c++·面试
IT爱学堂3 小时前
尚硅谷Java+AI大模型应用开发革新版本 2025年3月
java·开发语言·人工智能
不爱编程的小九九3 小时前
小九源码-springboot004-springboot智能阅读推荐系统
java·spring boot·后端
SCandL1524 小时前
Docker的实战应用
java·docker·容器
AC赳赳老秦4 小时前
OpenClaw 多源采集公开行业数据:从原始信息到研究报告初稿的自动化实践
java·c语言·c++·python·php·deepseek·openclaw
典典分享指南4 小时前
用指纹算法给文章去重:mid_signature 实战
jvm·maven·intellij-idea·jetty
Java成神之路-4 小时前
深入理解三大高频队列:ArrayDeque、LinkedList、PriorityQueue 方法、特性与场景选择
java