Hello, I am using influxDB as data source in Grafana and using flux query for data. Data is a PLC heart-beat data (boolean) and I wrote a simple logic to convert this timeseries boolean data into a simple status message “Alive” or “Dead”. I have to perform this for 10 PLC’s.
I want to use the ‘Status Panel’ but I cannot make it to work. I do not find sufficient documentation. Here is the query:
from(bucket: “Safety_Alarms”)
|> range(start: -20s)
|> filter(fn: (r) => r._measurement == “safety” and r.name == “Aging_1” and r._field == “heart_beat”)
|> keep(columns: [“_time”, “_value”])
|> sort(columns: [“_time”], desc: true)
|> limit(n: 2)
|> reduce(
identity: {first: true, last: true},
fn: (r, accumulator) => ({
first: if accumulator.first == true then r._value else accumulator.first,
last: r._value
})
)
|> map(fn: (r) => ({
_value: if r.first != r.last then “Alive” else “Dead”
}))
|> rename(columns: {_value: “result”})
I have multiple PLC’s and I want to monitor 1 metric for each of them in this status panel. The above code is for 1 PLC. I would appreciate some help with this task. Thank you.