I have few spring-boot microservices with actuator and exposed prometheus metrics. For example:
# HELP process_uptime_seconds The uptime of the Java virtual machine
# TYPE process_uptime_seconds gauge
process_uptime_seconds 3074.971
But there is no application
tag, so I'm not able to bind it to a certain application within a grafana dashboard...
Also I expect to have few application instances of some microservice, so in general it would be great to add an instance
tag also.
Is there any way to customize the standard metrics with these tags?
CodePudding user response:
The best way to add tags is to use the Prometheus service discovery. This keeps these tags out of your application code and keeps it from being concerned about where it exists.
However sometime if you absolutely need those extra tags (due to the service having extra insight that Prometheus service discovery isn't surfacing) you can't use the Java Simple Client (the Go client does support this though)
I turns out this feature is offered via a Micrometer feature called 'Common Tags' which wraps the Prometheus Java client. You setup your client so the tags are available via a config() call.
registry.config().commonTags("stack", "prod", "region", "us-east-1");