Hey,
I’m trying to get the duration of how long a workorder was within a process. To get this i have two time series which i call in two seperate tabels. I then unionize it with the Union() function.
When i use the group() function and then events.duration() the last value is the duration from the last time the workorder ID was written and the _stop time. Thats why i want to ignore the last value.
Is there a way to do this?
Here is the Query i use:
import “contrib/tomhollingworth/events”
toString = (tables=<-) =>
tables
|> map(fn:(r) => ({ r with ID: string(v: r.ID) }))
tab1 = from(bucket: “zone/autogen”)
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r._measurement == "M1"
)
|> pivot(
rowKey:["_time"],
columnKey: ["short","_field"],
valueColumn: "_value"
)
|>keep(columns:["_time",“ID_value”,"_stop"])
|>rename(columns:{ID_value:“ID”})
|>toString()
tab2 = from(bucket: “zone/autogen”)
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r._measurement == “M2” and
r.short == “ID_production”
)
|> pivot(
rowKey:["_time"],
columnKey: [“short”,"_field"],
valueColumn: “_value”
)
|> keep(columns:["_time",“ID_production_value_str”,"_stop"])
|> rename(columns: {“ID_production_value_str”: “ID”})
|>toString()
union(
tables:[tab1,tab2],
)
|>group(columns:[“ID”])
|>events.duration(
unit: 1m,
columnName: “duration”,
timeColumn: “_time”,
stopColumn: “_stop”
)
What i get is the following:
As you can see the last value in the duration column is to high.
I hope somone can help me with this.
I use InfluxDB 2.0 and Grafana 7.5 to visualize the data