I am a complete beginner when it comes to InfluxDB. So please excuse my vague question.
I have a database in which an entry is saved when the status of a production machine changes.
I would now like to add together for a specific day how long this machine is in the “manuell”, “aus” and “automatik” state and display this in a new table.
With some forum entries i was able to put together the following query, but the values do not seem to be correct and even if they were correct, i believe that i am outputting two tables in this way?
manuellSchaltdauer = from(bucket: "CL_State/autogen")
|> range(start: 2024-05-14T00:00:00Z, stop:2024-05-14T23:59:59Z )
|> filter(fn: (r) => r["_measurement"] == "State")
|> elapsed(unit: 1s, columnName: "manuellSchaltdauer")
|> filter(fn: (r) => r["_value"] == "manuell")
|> sum(column: "manuellSchaltdauer")
|> yield(name: "totalManuell")
ausSchaltdauer = from(bucket: "CL_State/autogen")
|> range(start: 2024-05-14T00:00:00Z, stop:2024-05-14T23:59:59Z )
|> filter(fn: (r) => r["_measurement"] == "State")
|> elapsed(unit: 1s, columnName: "ausSchaltdauer")
|> filter(fn: (r) => r["_value"] == "aus")
|> sum(column: "ausSchaltdauer")
|> yield(name: "totalAus")
I would be very happy about any help