A PromQL query like "mymetric == bool 2" will return 1 when the value is 2, and 0 otherwise.
You'll likely need to run this inside a subquery if you're doing time range aggregation over it. But if Grafana is doing the summarization that might not be necessary. On Monday 24 June 2024 at 13:38:03 UTC+1 Ben Kochie wrote: > IMO you need to fix your service metrics. Prometheus best practice is to > follow the pattern of probe_success. Boolean values are far easier to > handle. > > On Mon, Jun 24, 2024 at 2:36 PM Raúl Lopez <[email protected]> wrote: > >> Hello, >> I need to know in percentage the time my service has been available in >> the last month, last week, etc (dynamic value). >> The metric in question can return the values; 0, 1 and 2. >> >> 0 -> OK >> 1 -> Warning >> 2 -> KO >> >> The idea I have is to disregard value 1 and only treat my service as KO >> when it has returned value 2. I am trying to build in a Grafana >> visualisation for the SLA in percentage that my service has been available >> according to the time range that the user specifies in the dashboard. >> >> I've been doing some research and it seems that for this kind of cases it >> is not as simple as for example for those endpoints where Blackbox is used >> for example (as I cannot use probe_success). >> >> Could someone help me? >> Thank you in advance. >> >> Regards. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Prometheus Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/prometheus-users/a26d17b9-b507-413a-89d7-f95ca49ef725n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/prometheus-users/a26d17b9-b507-413a-89d7-f95ca49ef725n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c4ec7e1e-d850-4a1e-bc43-de33a12d464dn%40googlegroups.com.

