Hi Anaisdg,
Thanks for your reply.
I can’t really think of a numerical value but I can show a graph example.
In that image, it shows the graph on the right side going down and instantly counting again, so the uptime should be minimally impacted, not 20.2%.
The query I described in my original post was a Grafana query which gets the uptime (displayed in days in the second graph) and I made graphical changes in Grafana to display it as a percentage.
The query is set to select the last non null value and the default display is in days.
I’ve done the following yesterday:
- Threshold is amount of seconds in a day, so it will not count if a device is down for a day.
threshold = 86400
from(bucket: "librenms")
|> range(start: -30d)
|> filter(fn: (r) => r.hostname == "au-brockman4-ves-sw-01" and r._field == "uptime")
|> aggregateWindow(
every: 5m,
fn: (column, tables =<-) => tables
|> reduce(
identity: {above_threshold_count: 0.0},
fn: (r, accumulator) => ({
above_threshold_count: if r._value >= threshold then
accumulator.above_threshold_count + 1.0
else
accumulator.above_threshold_count + 0.0,
}),
),
)
This somewhat does what I need it to but still seems to drop to 0 (_time=2022-04-11T00:20:00.000Z OR _time=2022-04-11T00:30:00.000Z)
I think this may be because there isnt an entry for that time?
See the below picture of this query which shows no entry for the two times mentioned above.
from(bucket: "librenms")
|> range(start: -30d)
|> filter(fn: (r) => r.hostname == "au-brockman4-ves-sw-01" and r._field == "uptime")
I tried the state duration and state count however I think I need a threshold for it to work properly?
from(bucket: "librenms")
|> range(start: -10d)
|> filter(fn: (r) => r.hostname == "au-brockman4-ves-sw-01" and r._field == "uptime")
|> stateDuration(fn: (r) => r._measurement == "uptime", column: "stateDuration", unit: 5m)
How would I use the map function? Again I’m not very experienced in Flux…
Sorry for such a long reply…Thank you for your help so far!