0

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?

Alex.Sh
  • 123
  • 1
  • 2
  • 7
  • what does that "0" state for 4 minutes mean? could you provide details? What is your query and what you are expecting/ – Sriram May 24 '17 at 15:11
  • 0 and 1 - just a metric values. I'd like to know how long metric was in "0" value (period), in this example it's 4 minutes (05:07 - 05:09 and 05:16 - 05:18 , 4 minutes in total) – Alex.Sh May 30 '17 at 21:11

1 Answers1

0

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

deniszh
  • 774
  • 1
  • 5
  • 14
  • Ah, and you should set "Time range" for stat panel for a timespan of your SLA calculation period. – deniszh May 19 '17 at 12:23
  • I've edited initial description. What I'm trying to get is the duration metric was in some state, based on it timestamps. – Alex.Sh May 20 '17 at 11:28