Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there any way to add `application` tag to standard prometheus micrometer metrics?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there any way to customize the standard metrics with these tags?

>Solution :

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");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading