How to sum up running time for shift totals


I am seeking some advice on how to set up my dashboard in grafana.

i have an instance of grafana that is connected to influxdb. It is querying 10 run signals for 10 different machines, i currently have my dashboard set up with a state timeline visualisation which simply shows when the machine is running and stopped over a time period. What i want to achieve is a table which sums together the time the machine is running over 3 separate 8 hour shifts and at the end of the shift populate a field of a table with the time it has ran, then start counting again.

is this something i can do within grafana?

Any help would be massively appreciated

thank you

Can you share your query which is behind your state timeline visualization?

Hello, here is my query for the state timeline.

As I said at the moment this just displays the value as true or false.

from(bucket: “Demo”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Carding Production”)
|> filter(fn: (r) => r[“_field”] == “Card 1 Running” )
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)

On the visualisation i have another 9 of the same queries for each different carding machine.

Thank you

Hi @lewisphillips403

Could you please post your query above into Influx Data Explorer and share the output here in CSV format?