Grafana / Graphite - the time metric was in some state

467 Views Asked by At

I have metric "monitor.status" with values 0 and 1. 0 indicating service down state and 1 - up state.

I'd like to render downtime period in seconds in Single stat panel. How to get the time metric was in 0 state and render it?

Example:

Value - Timestamp (just h:m to simplify)
1 - 05:00
1 - 05:05
0 - 05:07
0 - 05:09
1 - 05:11
0 - 05:16
0 - 05:18

Here metric was is "0" state for 4 minutes. This is the value I'd like to get.

Do you have any suggestions how to track downtime period correctly in graphite?

1

There are 1 best solutions below

2
On

In this particular case, it can be e.g.

integral(divideSeries(monitor.status, countSeries(monitor.status)))

Example: If monitor.status is [0,0,1,1,1,1,1,0,0,1] then countSeries(monitor.status) = [10,10,10,10,10,10,10,10,10,10] and divideSeries(monitor.status, countSeries(monitor.status)) = [0,0,0.1,0.1,0.1,0.1,0.1,0,0,0.1] and integral() of series above will give you 0.6 at the end of result which stat will show to you. Just do not forget to change Max data points of stat panel to 1, otherwise, you'll get less than 0.6