Duration how long condition is set (e.g flag == true)

  • What Grafana version and what operating system are you using?
    grafana-enterprise 10.4.0 (latest)

  • What are you trying to achieve?
    in prometheus TSDB i’m exporting the state of a flag - representing “state==1” when a condition is active or “state==0” when condition is passive. the TSDB is scratching the state-value together with a timestamp. i want to know - how long “state” was “1” in the last “12h”

  • How are you trying to achieve it?
    in my existing attempt - i’m counting time outside TSDB and write the final runtime after state-changed. this works fine, if state often changes. but for long running states, you never get the current-runtime accurately.

  • What did you expect to happen?
    i’m looking for something which is “analysing an vector for seconds a condition is true”.