【问题标题】:Spring PushGateway pushes metrics without an instance tagSpring PushGateway 在没有实例标签的情况下推送指标
【发布时间】:2019-09-16 13:23:46
【问题描述】:

这是我的配置:

management.metrics.export.prometheus=true
management.metrics.export.prometheus.pushgateway.enabled=true
management.metrics.export.prometheus.pushgateway.push-rate=1m
management.metrics.export.prometheus.pushgateway.base-url=<IP>:9091
management.metrics.export.prometheus.pushgateway.job=myjob

查看 PushGateway 的 &lt;IP&gt;:9091/metrics 端点,我看到以下标签:

{instance="",job="myjob"}

理想情况下,我希望“实例”是正在运行的服务的 IP 地址和端口。

值得一提的是,我在 Promethoues conf 中使用了honor_labels: true

如何设置(如果可能,自动设置)实例标签?

谢谢

【问题讨论】:

    标签: spring-boot prometheus prometheus-pushgateway


    【解决方案1】:

    以下 - 将其设置为分组键映射中的键值 - 应该可以解决问题:

    management.metrics.export.prometheus.pushgateway.grouping-key.instance=${hostname:localhost}:${server.port}
    

    您不一定需要设置“job”属性,因为它派生自spring.application.name,然后是回退。见here

    【讨论】:

    • 谢谢。我将为以后的读者提一下,我最终自己创建了PrometheusPushGatewayManager bean,以便将 instance 标记设置为InetAddress.getLocalHost().getHostAddress()
    • 必须设置“instance”属性才能查看指标中的值
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多