prometheusprometheus-blackbox-exporter

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

Solution

  • Use the following PromQL:

    count_values("status", probe_http_status_code)
    

    More info in Prometheus documentation here.