Search code examples
prometheuschaininggrafana-variable

Chaining grafana variables


How do you chain grafana variables to filter template panels Grafanav6.2.5 Datasource: prometheus Data: Kubernetes metrics

I want to be able to select the first variable e.g. Cluster, then select the second variable which shows only say nodes in that cluster. Or select a Namespace variable and only pods in that namespace

I'm using Node Exporter and Kube-State-Metrics with some standard dashboards from Git etc which work fine but don't want to apply the filter at the panel level.

label_values(node) Works fine showing my available nodes.

label_values($cluster, node) Parse error

label_values({cluster="$cluster"}, node) Doesn't work and breaks the variable instead of showing nodes in that cluster.

I either get parsing errors or the variable declaration saves without complaining but doesn't function as expected or at all. Has anyone ever had this working?


Solution

  • Probably you've got wrong order of variables in list. When At top you've got cluster, and second is node and they're refreshing on time range change it should work. You can also try

    label_values(kube_node_info{cluster="$cluster"}, node) 
    

    Which will go through less metrics each time