To count the number of specific values

i just scraped values of uptime from UptimeKuma using Prometheus with a query like this (monitor_status{monitor_name=“Example-Server”}). How can I calculate the total count of values that are 2 ?

If I have a bunch of data with 2’s in it:

you can use couple of transformations: 1st filter out the values equal to 2, then divide the 2’s by themselves to get 1’s, then add up all the 1’s

1 Like

If I want to calculate the total value that contains 0, how do I do it?

you can’t divide by zero, so in that step, add a 1 instead…


This is my setup, and I’m utilizing the filter from the data transformation and leveraging the count value from the legend
Thanks !!

1 Like