Is there a way to get the cluster name of Kubernetes in Grafana variables with prometheus data source?

11/18/2020

I am trying to get the cluster name with a variable in Grafana and I need it to be retrieved from the prometheus data source.

I tried with label_values(kube_pod_info, cluster) and label_values(up, cluster) but it's not working for me

Any ideas how to achieve this?

-- Javi Hernandez
grafana
kubernetes
prometheus

1 Answer

12/22/2020

You need to have a "cluster" label defined in the "kube_pod_info" metric.

To resolve this you can just use the "instance" label instead or create a "cluster" label in the Prometheus configuration using the "instance" label to map the IPs to known cluster names, for example.

-- Marcelo Ávila de Oliveira
Source: StackOverflow