Gauge disappers when value to show is 0

Hi experts,

I created a Gauge visualization with 2 queries, hence I have two Gauges side by side (if screen size allows), which is fine.
The gauges monitors incoming data from different sensors. I count the incoming data each 2 hours, compare it with the expected number of data points and calculate the percentage of received data points.
My data source is Influxdb, I’m using InfluxQL as query language.
My queries looks like:
SELECT (count("TempC_DS") / 6 * 100) FROM "bumblebee_box" WHERE ("device_id"::tag = 'lht65-hummelkasten') AND time > now() - 120m GROUP BY "device_id"::tag

I expect to receive each 20 min a new datapoint from a sensor, hence it should be 6 in 2 hours, which would give 100(%).

So far everything works fine. But when a sensor is not sending at all and I have received 0 datapoints during the last 2 hours the gauge simply disappears :confused:. Actually it would be OK, if a 100% gauge disappears, since the related sensor does not need my attention. But if the count is 0 I need the gauge to grap my attention.

Any idea what I can do to display 0 received datapoints as a gauge showing 0?

I’m using Grafana v11.1.0 on Ubuntu.

Thanks
Christian

OK, wasn’t aware that this question is so difficult that nobody can answer it! :hushed:
Or maybe so easy that nobody feels it’s worth to answer it?
Or, and I think that’s most likely, I wasn’t able to make myself clear (English is not my native language).

Anything that is not understandable and I could make more clear?

Grafana displays as many gauges as your query returns.

Using Flux I solve similar to your problem in the following way (if there is no real data, I manually return 0):

import "array"

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

    return length(arr: columnsArray) == 0
}

dataQuery = <REPLACE BY REAL DATA QUERY>

zeroQuery =
    array.from(
        rows: [
            {
                _value: 0
            },
        ],
    )

if not isEmpty(tables: dataQuery) then
    dataQuery
else
    zeroQuery

Not sure that InfluxQL provides such a flexibility though…

1 Like

Sorry, I was on vacation, hence the late answer.

I solved this case by using separate gauges for each query (each sensor). When there is no data the gauge is still there and shows “No data” which is not “0” but I think it puts the message across quite well.

OK, Flux again.
Here influxdata’s policy is a bit annoying (but as far as I can see I’m really not the only one that has this feeling):

  • Flux is the tool in influxdb V2
  • It’s no longer supported (or at least not the preferred query language) in influxdb V3
  • The OSS version of V3 is still not available
  • You need some time to understand and learn Flux

Hence I have to invest some time to learn Flux, if I want to do more advanced stuff now. But in a few month that acquired knowledge might be more or less useless. Yes I know, there might be ways to continue the usage of Flux in V3. But it feels awkward to learn something new that you already know can be only used with some workaround in the future.
Ok, but @ebabeshko , that’s not your fault, so I should stop moaning!

Thank you anyhow for your input!