TIL: Returning 0 instead of null in Prometheus
| 1 min read
Annoying No data
on my Grafana charts
Another short entry, but I found it to be a nice quality of life improvement for when I'm writing PromQL queries for Grafana Dashboards. When you're writing a query and there's no data, null
will be returned and will often result in the whole PromQL query returning null
, resulting in a sad No Data
dashboard. Luckily, there's a nice way of defaulting to 0 instead of null! In order to do that, you can use OR on() vector(0)
after the possibly null-ish part of the query.