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

相关推荐
CodeAmaz2 分钟前
统一发包管理(Maven 仓库)详细步骤
java·maven·运维开发·个人开发
没有bug.的程序员14 分钟前
Spring Cloud Bus 事件广播机制
java·开发语言·spring boot·hystrix·feign·springcloudbus·事件广播机制
找不到、了19 分钟前
Java系统设计知识整理《1》
java·开发语言
程序猿七度23 分钟前
【Excel导入】读取WPS格式嵌入单元格内的图片
java·开发语言·wps
用户2986985301437 分钟前
Java: 为PDF批量添加图片水印实用指南
java·后端·api
q***31831 小时前
微服务生态组件之Spring Cloud LoadBalancer详解和源码分析
java·spring cloud·微服务
大头an1 小时前
Spring事务在微服务架构中的实践与挑战
java
BugShare1 小时前
嘿嘿,一个简单ElasticSearch小实现
java·大数据·spring boot·elasticsearch
小兵张健1 小时前
Java + Spring 到 Python + FastAPI (一)
java·python·spring
Seven971 小时前
剑指offer-37、数字在升序数组中出现的次数
java