Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
1.4k views
1.4k views

On a Grafana dashboard I have a stat panel showing the number of hosts that have operating system updates pending. The PromQL query looks like this (os_updates_pending is a custom OS-agnostic metric):

count(sum (os_updates_pending) by (hostname) != 0)

This works well if there are hosts with pending updates, but if there aren't I'm getting "No data" instead of "0" as a result. I know I could set the "No value" option to "0" to get a zero displayed instead, but the data link for clicking through the panel to a details view still won't work (because the value is still empty, not 0). How can I fix that?

in Sysadmin
by (125)
3 20 38
edit history

Please log in or register to answer this question.

1 Answer

0 votes
 

To get "0" as a fallback value append or vector(0) to your query:

count(sum (os_updates_pending) by (hostname) != 0) or vector(0)
by (125)
3 20 38
edit history
...