Grafana dashboard doesn't display custom legend value if prom query returns only one result

441 Views Asked by At

I have a prom query that returns my pvc usages if they are over a certain threshold in a Gauge chart.

Example:

((kubelet_volume_stats_used_bytes / kubelet_volume_stats_capacity_bytes) * 100) >= 30

This query returns: {endpoint="https-metrics", instance="89.247.325.217:10250", job="kubelet", namespace="postgres", node="pool-1c5r15h-4pwmenbjse", persistentvolumeclaim="data-postgres-postgresql-0", service="kube-prometheus-kubelet"}

In my legend values field, I reference {{persistentvolumeclaim}}.

This works completely fine if the query returns multiple results. For example if I change the threshold of the query to >=30

(I overrode the display name for the pvc names, hence it shows "PVC: ...". The issue is also not related to the override, I tested it)

[Legend values displayed correctly] enter image description here

Now if I change the threshold so that the query only returns one result, the label value is not displayed eventho it is being returned by the query. The label is showing when I choose the time series chart though. If I choose the Stat or Gauge chart the label is not displayed.

[Legend value not being displayed] enter image description here

If I change the chart to the time series chart and remove the {{persistentvolumeclain}} reference from the legend, it clearly returns the result containing a persistentvolumeclaim field:

[result contains pvc field] enter image description here

Does someone know if this is a grafana issue or might I have misconfigured something?

Tried explicitly overriding display name. Tried different chart types but it only works on the time series chart and state timeline chart.

0

There are 0 best solutions below