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

相关推荐
掉鱼的猫25 分钟前
把 OpenAPI 接入 Agent Harness:零代码让 Agent 听懂你的 REST API
java·llm·agent
lzhcoder29 分钟前
Spring Boot 集成 Kafka:先跑通 Demo,再避开那 80% 的人踩过的坑
java·kafka
plainGeekDev1 小时前
ProGuard → R8
android·java·kotlin
带刺的坐椅1 小时前
把 OpenAPI 接入 Agent Harness:零代码让 Agent 听懂你的 REST API
java·ai·llm·agent·solon·restapi·openapi
spider_xcxc1 小时前
Prometheus + Grafana流程搭建总结
grafana·prometheus·云计算运维
Geek-Chow2 小时前
微服务认证与授权:01 — 概念
java·前端·数据库
KobeSacre2 小时前
DelayQueue 源码
java·开发语言
Wang's Blog2 小时前
JavaWeb快速入门: Filter与Listener核心详解
java·filter·listener
zfoo-framework2 小时前
mongodb性能调优 1.从慢查询分析索引 2.掌握索引最左匹配原则!!!
java
AIGS0012 小时前
企业AI落地:从RAG到AgentRAG的技术跃迁
java·人工智能·人工智能ai大模型应用