Default Value for a count expression

  • What Grafana version and what operating system are you using?

Grafana 8.5.9

  • What are you trying to achieve?

I am trying to count the number of seconds in a range where the sum of a statistic exceeds a threshold.

  • How are you trying to achieve it?

With an influx query that is being fed into a grafana dashboard. I am using a select that looks like this:

SELECT count(“events_per_second”) as “busy_seconds” FROM (SELECT sum(“events_processed”) as “events_per_second” FROM “my_app_stats” WHERE $timeFilter GROUP BY time(1s) fill(0)) WHERE “events_per_second” > 900

  • What happened?

I get a total number of “busy seconds” for time ranges that have at least 1 busy second.

I get nothing when there are 0 busy seconds.

  • What did you expect to happen?

I wanted to get a value of 0 as a value for “busy_seconds” for both of the above cases.

  • Can you copy/paste the configuration(s) that you are having problems with?

No

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

No

  • Did you follow any online instructions? If so, what is the URL?

No.

I was able to use a grafana value transformation to transform the null into a zero:

I am curious if there is a better way to do this but I have resolved my issue for now.

Did you fill in anything in the box “No Value”? What changes in your results (if anything)?