Single Stat Display % of time a value was 100% over a moving period

Grafana V8.5.3
Influx DB back end

In influx we have a metric for Service availability - its either 0 or 100 for each type_instance
This can be graphed and the current state show
The customer wants to see a stat panel for this metric expressed as a percentage of the time the value was 100% out of the time period selected - so essentially a moving window based on the time range chosen

At present I am stumped on the best way to achieve this an I am hoping one of the fellow grafana users out there can assist.

The end result would be a Time Series Graph showing the returned values - either 0 or 100
and a stat panel showing the % that the value was 100 in the time filter selected.

Turns out to be a lot easier than I thought - in a stat - the query is

SELECT 0 + mean("value") FROM "value" WHERE ( "type" = 'type1' AND "type_instance" = 'instance1') AND $timeFilter GROUP BY time(1m) fill(null)

1 Like