Keet Sugathadasa
Keet Sugathadasa

Reputation: 13502

Prometheus Query - Group by values and return a count

I have a metric that returns a few unique values for each timeseries. (This is from Prometheus Blackbox Exporter). See example below

enter image description here

How can I group these by value and return a count. The following is the expected outcome

{status="400"}      1
{status="0"}        0
{status="200"}      2

Upvotes: 1

Views: 4860

Answers (1)

Use the following PromQL:

count_values("status", probe_http_status_code)

More info in Prometheus documentation here.

Upvotes: 3

Related Questions