title: Calculate the duration in which a Prometheus metric had a certain value?
body: <p>Is it possible with Prometheus to calculate a duration (for example in seconds) in which a metric had a certain value?</p>
  
  <p>A simple example would be an <code>up</code> metric which can have two values: <code>1</code> or <code>0</code> to indicate if a system is running. Imagine that since last week the system was going up and down several times. </p>
  
  <p>I'd like to be able to calculate the total number of seconds the system was down during that period of time.</p>