Grafana should not hide Gauges with "no data"

Hello,

I have a basic question. I did not find the answer after spending some time searching for it.

I have a few gauges like this

They all use a query similar to this:
SELECT last(“value”) FROM “autogen”.“Lutz_Heiz_Status_Stellgroesse” WHERE $timeFilter GROUP BY time($__interval) fill(previous)

(to make an average of a (quasi-binary, but actually numerical) signal after forwardfilling.)

However some of the gauges are not shown here. I am talking about the ones where the query above returns “no data” → 0 results from Influx.

I want to show them as zero because that’s what it will practically mean in my case. I can’t manage to make it work. I found some ideas with the “or on() vector(0)” approach to return a zero number instead of “no data”. But I couldn’t make it work probably because it’s using a newer query language or newer features that I am not familiar with.
My task sounds simple enough, right? So I assume there is an easy solution that I am missing)

(It would show up with “no data” if I only have 1 gauge, but since I have several it “automatically” seems to hide the “no-data” ones; therefore also the “override no data” thing does not work here)

I use Grafana v11.0.0 (277ef258d4)

Grafana doesn’t know how many gauges should be shown if your query doesn’t return them.

So the query should be updated to return fixed number of values, regardless of data availability (i.e. return dummy data if there is no real).

2 Likes

Thanks for your response. Let me be more clear. I am not making one query (like the one that was described above) but I am making multiple of those. Like 8 or so. So grafana knows exactly how many gauges there are in theory. Some automatism seems to hide the gauges that have „no data“. If all the gauges would just show up (either with the numerical data or with a „no data“ text) I would understand and agree to the behavior (and if I could apply the override / value mapping thing that converts the „no data“ into a zero or something then it would be even better / what I want) but the gauges simply do not show / disappear .

It feels like there should be a switch somewhere like „hide empty gauges“ that is auto enabled and hidden from me. I don’t know. Or is it even a bug in v11 - I cannot say.

what does the data rerurned look like in the data view

There is no mapping ‘1 query == 1 gauge’ for Grafana. For example I could have 2 queries, providing data for 6 gauges:

Or 1 query providing data for 7 gauges:

So that’s a query task to return data (either real or dummy), and Grafana’s task is just to visualize it.

With flux I use the following approach if I always need to have data:

import "array"

isEmpty = (tables) => {
    columnsArray =
        tables
            |> columns()
            |> findColumn(fn: (key) => true, column: "_value")

    return length(arr: columnsArray) == 0
}

dummyData =
    array.from(
        rows: [
            { ...  },
        ],
    )

realData =
    from(bucket: "my-bucket")
        |> ...

if not isEmpty(tables: realData) then
    realData
else
    dummyData

Another approach is to have 1 panel == 1 gauge. May be it fits in your case?

1 Like

I made this panel to illustrate it. I have two queries here.

  • one for “spielzimmer”, which will return “no data”
  • one for “WCBad”, which will return some valid values close to zero

at first, I have the valid query hidden. this is the result: showing one gauge with “no data” for spielzimmer as it should be:

Query inspector result:
image

but as soon as I unhide the second (valid) query, the gauge for the “no data query” (spielzimmer) automatically disappears and I can only see the one for WCBad (valid):

Query Inspector:

didn’t quiet answer my question, but try this.

if possible I would do this all in flux. check to see if there are no rows returned, if so send back mock data with 0 value

we do that easily in sql server query. Is that doable in flux?

Currently I use the InfluxQL, not flux! The InfluxQL syntax looks to me more familiar (SQL-like) than flux. Since the future might be to use SQL in Influx, hopefully I don’t need to familiarize with flux at all. (However I cannot use SQL yet on my X-Influxdb-Version: 1.8.10 (latest on Home Assistant)).

With all my other dashboards / visualizations I managed well with InfluxQL so I was hoping I don’t have to change to “flux” now because of this. Should there not be an easier way? At the end of the day I just want to override an empty/nan value with a zero…

1 Like

oops O confused @ebabeshko response with yours sorry

can you do what was mentioned using influxql

hm… ok can we say at least if the behavior is a bug or a feature? (i was on an older version of grafana for a long time and upgraded just before I created/modified this panel, so I cannot tell)

imo not a bug until you can prove otherwise

in all other datasources that I have used it has the same behaviour. but you can bypass it by returning some data by checking that there is no data like you would in a left join

1 Like

stand up that same older version and recreate that datasource and that dashboard or reimoprt it and see if a regression bug might have been introduced. the onus and due diligence falls on you

1 Like

Ok, I‘m not sure if I can roll back on Home Assistant but I can install an older version of grafana on my windows machine or RPi - will give it a try to see if behavior is more understandable

1 Like

not sure anyone here recommended you upgrade or rollback HA. the idea of rolling back was specific to grafana as you indicated it was grafana you upgraded?

I think rollback would not help in this case.

If it can’t be sorted out by datasource capabilities, then this is the way:

yes, you are right. I quickly checked with grafana 9.5.20 to confirm. and behavior is the same:
the “no data” gauges do not show up if at least one gauge has data (so it seems to be the intended behavior since a long time and nothing that was changes recently). Still would be nice to have a boolean to enable this behavior or disable it (show all gauges) → possible feature request?

thank you for the solution-oriented approach to make 9 small panels with 1 gauge each. I thought about this as well and might do this if it will not look bad (depending also how it looks on the phone / mobile browser / small screen).

I just noticed one thing that is annoying in v11 that was not there e.g. in 9.5.20:

We already talked about the case where we have no data. and it gets handled nicely in the 1-gauge-per-panel case with the functionality of “No value: What to show when there is no value” → Entered 0.0% which is true in my case.

I run two expressions on the raw results: fill NaNs with 0 and then multiply everything by 100.

In v9 does two expressions seem to fail silently and everything is fine in case of no data. In v11 I get the “attention symbol” next to the panel title I rather not have.

PS: I am not questioning if it is useful or not to have this warning. but the user should have the option to quiet them / disable them if wanted. I found this thread where people even have to resort to some hacks to get rid of this Cant get rid of "items dropped from union" icon when using Math expression · Issue #84133 · grafana/grafana · GitHub

EDIT:
I found a way that works for my specific case: The “attention symbol” did not appear when filling the NaNs but when I multiply by 100 with the math expression (for no-data case). So I have replaced this math expression with a transformation. Now the gauge works as expected. No “Attention Symbol” when there is no data. (I still have to create one panel per gauge like suggested by @ebabeshko

I’m using the “Value mapping” for this event:

marked this as solution because at the end I used 1 panel == 1 gauge to avoid any trouble…