Here's my config:
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
Looking at the <IP>:9091/metrics
endpoint of PushGateway, I see the following tags:
{instance="",job="myjob"}
Ideally, I'd like that "instance" will be the ip address and port of the running service.
It is worth mentioning I used honor_labels: true
in the Promethoues conf.
How can I set (automatically if possible) the instance tag?
Thanks
The following - setting it as key-value in the grouping-key map - should do the trick:
management.metrics.export.prometheus.pushgateway.grouping-key.instance=${hostname:localhost}:${server.port}
You don't necessarily need to set the "job" property as it is derived from spring.application.name
and then a fallback. See here.