I would like to request for your help to compute the duration of each of a system state.
I am using Prometheus v2.36.2 and Grafana v9.0.3. I have a Prometheus gauge that I've called: load_gauge. I can have four states with this metric:
- load_gauge >= 10 => Overload State,
- load_gauge <= 5 => Underload State,
- load_gauge > 5 && load_gauge < 10 => Regular State,
- If prometheus is disconnected: State is Off.
I am trying to show on Grafana, for each given State, the duration of the state for the last 24 hours. A sample output would look like this: Overload for 1 hour, Underload for 6 hours, Regular for 2 hours, Off for 15 hours.
I played a lot with Grafana's metrics browser to build a query, something like:
count_over_time((load_gauge{job="prometheus"} > 10)[1d:])
but it does not seem to do the job. I also played with Grafana panels like Pie Chart, but it would show me just some percentage for all the states for the last 24 hours. Do you know if it is possible for me to get the duration directly, in terms of hours or minutes? Where should I eventually make the changes: from prometheus by aggregating metrics, or from Grafana?
Thank you in advance for your response,
Josh Verdi