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

相关推荐
怒放吧德德21 小时前
Spring Boot 实战:RSA+AES 接口全链路加解密(防篡改 / 防重放)
java·spring boot·后端
郑州光合科技余经理1 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
weisian1511 天前
JVM--20-面试题6:如何判断对象可以被垃圾回收?
jvm·可达性算法
大大水瓶1 天前
Tomcat
java·tomcat
dustcell.1 天前
haproxy七层代理
java·开发语言·前端
游离态指针1 天前
以为发消息=下单成功?RabbitMQ从0到秒杀实战的完整踩坑笔记
java
蚊子码农1 天前
每日一题--JVM线程分析与死锁排查
jvm
BD_Marathon1 天前
工厂方法模式
android·java·工厂方法模式
玹外之音1 天前
Spring AI MCP 无状态服务器实战:构建AI智能用户管理系统
java·后端
java干货1 天前
Redis 的 ZipList 是什么?它是怎么解决内存碎片问题的?
java