关于 prometheus 向 gateway 推送的备忘

1,POM

<dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient_servlet</artifactId>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient_pushgateway</artifactId>
    </dependency>



2, application.yml

spring:

metrics:
   tags:
     application: ${spring.application.name}
     instance: 192.1.1.1
     profile: ${spring.profiles.active}
   export:
     prometheus:
       pushgateway:
         #pushgateway地址
         baseUrl: http://127.0.0.1:9091
         #推送周期
         pushRate: 15s
         #job定义名
         job: ${spring.application.name}
         #启用推送
         enabled: true

posted @ 2022-06-13 16:01  张保维  阅读(139)  评论(0编辑  收藏  举报