这是我的配置:
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
。
如何设置(如果可能,自动)实例标签?
谢谢
答案 0 :(得分:1)
以下操作-将其设置为分组键映射中的键值-应该可以解决问题:
management.metrics.export.prometheus.pushgateway.grouping-key.instance=${hostname:localhost}:${server.port}
您不必设置“ job”属性,因为它是从spring.application.name
派生而来的,它是一个后备。参见here。