How to plot a machine cycle?

Hi Everyone,

We have a requirement wherein we are recording Pressure in our machine to a particular measurement. The Machine starts it Cycle when pressure is > 80 and cycle ends when Pressure < 1. We are using Grafana Timeseries Panel to plot the cycle Graph. I was wondering how can we achieve this? So far I have below query:

from(bucket: "MyBucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "MyTag")
  |> aggregateWindow(every: v.windowPeriod, fn: (column, tables=<-) => tables 
    |> quantile(q: 0.99, column:column), createEmpty: false)
  |> map(fn: (r) => ({ r with _value: (if r["_value"] > 80 then 1 else 0) }))

Problem with above query is that it ends the cycle as soon as pressure < 80 but I need to end the cycle only when it is < 1 and next cycle should start when again pressure > 80.

I think I am missing something trivial here.

Could someone please point me in the right direction here ?

Hi. I am trying to envision this in Grafana, and what I would expect is a time series graph going up and down, sort of like this:

Is your goal to have Grafana display ONLY those sections where pressure reaches 80 and then falls below 1? In other words, just the sections like this?

I do not think Grafana (or Influx) can (via a query) filter out only the time slices you wish to view. You can set alerts or colored thresholds to indicate when you exceed 80 and when it falls below 1.

Maybe I am misunderstanding your goal?