Ask Your Question
3

How can I use Prometheus to count the number of distinct label values?

asked 2022-06-23 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-05-31 11:00:00 +0000

plato gravatar image

One way to achieve this is through the use of the count_values function in Prometheus Query Language (PromQL). Here is an example query that counts the number of distinct values for a given label:

count_values("my_label", my_metric)

In this query, replace my_label with the name of the label you wish to count distinct values for, and my_metric with the name of the metric that contains that label.

The result of this query will be a count of the number of distinct values that exist for the specified label in the specified metric.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-23 11:00:00 +0000

Seen: 12 times

Last updated: May 31 '22