How to hide zero or null values in Legend in Grafana 8?

  • What Grafana version and what operating system are you using?
    Grafana OSS v8.1.7, Linux

  • What are you trying to achieve?
    Hide null values and zero values from Legend in my Panel

  • How are you trying to achieve it?
    Reading the docs but not finding anything relevant other than possibly overrides

  • What happened?
    Could not find any docs about it

  • What did you expect to happen?
    Find buttons or some other form of option for “Hide values with only zeros” and “Hide values with only null values” like we had with previous (v7.x) versions.

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

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

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

1 Like

This feature in the graph panel was not added to the newer time series panel. I am not sure if it will be added in the future, or not :+1:

Hopefully this would be added, in our use case this is also annoying and blocking us from migrating from the old graph panel into TS panel.


Seeing a similar (the same?) thing here - related to this capability in the older series (to hide the legend for all-null or all-zero series),

Assuming this is what you mean? And any more thoughts on this being added to the new Time Series panel? I’m the same here - need this to move to the new one.


Hi everyone,

the best chance for getting a feature request added is to pick one of these three null-related discussions and upvote it. Or create your own if these don’t fit:

Hi Matt,

None of the suggested results is what we are asking for in this thread so I have opened a new discussion for it here: New time series graph missing "Hide series with zeros/null" capability · Discussion #44246 · grafana/grafana · GitHub

We would also need this capability to move to the new time series panel.


1 Like
1 Like

I got this to work in the new timeseries by doing this:
transformNull(-1) to turn all the nulls to -1 (or a value that works for you)
followed by
Which has the effect of hiding all the missing values in the graph and the tooltip.
I did find that a lot of other functions just made everything disappear for some reason, or didn’t do anything. But the functions above worked!

Also, had no problem getting the tooltips to sort by value. It’s there, just dig a little.


I too ran into this problem when preparing dashboards for an upgrade from Grafana 7.5.16 to Grafana 8.5.9.

I wanted to hide series that had only 0 values. But for the other series, I needed to keep the 0 values. So I couldn’t just add > 0 to my query, as this would remove all 0 values and create gaps in the still visible series.

I solved the issue as follows:

  1. My metric (hana_db_delta_merge_count_5m) can only have positive values, so if the sum of all values over the selected time range is 0, this means that all values of the series are 0. I created a variable that extracted a unique label (motivation) from all series where the the sum of all values was > 0 (that should not be hidden).

Query: query_result(count by(motivation) (sum_over_time(hana_db_delta_merge_count_5m{namespace="$namespace"}[$__range]) > 0 ) )
Regex: .*motivation="(.*?)".*

  1. In the time series panel query, I then limited the selection to the labels of this variable.

Best regards

This topic was automatically closed after 365 days. New replies are no longer allowed.