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

时间:2019-09-16 13:23:46

标签: spring-boot prometheus

这是我的配置:

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"}

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

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

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

谢谢

1 个答案:

答案 0 :(得分:1)

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

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

您不必设置“ job”属性,因为它是从spring.application.name派生而来的,它是一个后备。参见here