Spring PushGateway 推送没有实例标签的指标

Spring PushGateway pushes metrics without an instance tag

这是我的配置:

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 的 <IP>:9091/metrics 端点,我看到以下标记:

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

理想情况下,我希望 "instance" 将成为 运行 服务的 IP 地址和端口。

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

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

谢谢

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

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

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