I have a binary state metric in Prometheus (i.e 'on'/'off'), and I'd like to change it to an 'on duration' series (i.e. the durations the value was 'on').
For example, consider the following series:
2022-02-02T00:00 Off
2022-02-02T00:01 On
2022-02-02T00:02 On
2022-02-02T00:03 Off
2022-02-02T00:04 On
2022-02-02T00:05 Off
Will be transformed to:
2022-02-02T00:01 120s
2022-02-02T00:04 60s
Any help would be much appreciated.