Modifying labels on default Prometheus metrics

39 views
Skip to first unread message

Ayush Kumar

unread,
Sep 8, 2020, 8:35:01 AM9/8/20
to Prometheus Users
Hi Everyone,

I work with .NET Core applications and we use Prometheus along with Grafana for dashboarding. I wanted to know if there's a way to add a new Label to the default metrics that Prometheus has, for example:
http_requests_duration_seconds_count

This metric has a few default labels like action. I wanted to add one more label called callerID to this for my application.

Is it possible to modify the default metrics to include new labels ? If so, could you point me towards some documentation on how to do this ?

Thank you
Ayush Kumar

Stuart Clark

unread,
Sep 8, 2020, 10:40:55 AM9/8/20
to Ayush Kumar, Prometheus Users
What is callerID?

If it is something to do with the end user calling a system then it
would be strongly advised not to have such a label - things like user
IDs, usernames or IP addresses have possibly infinite (or generally
large) cardinality and can quickly cause issues.

However if it is something to do with the service/application itself the
general approach would be to either:

1. Add such labels via relabeling in your scrape config

2. Not add the label at all, and instead use role metrics as described
at https://www.robustperception.io/how-to-have-labels-for-machine-roles
&
https://www.robustperception.io/exposing-the-software-version-to-prometheus

Reply all
Reply to author
Forward
0 new messages