Matt
Matt

Reputation: 4387

Grafana templating merge variables

I'm looking for a solution to merge two templating variables in grafana(data source: prometheus).

My use case is:

I've my first variable:

deployment = label_values(kube_deployment_labels{namespace="$namespace"},deployment) 

and the second one:

statefulset = label_values(kube_statefulset_labels{namespace="$namespace"},statefulset)

What I'm looking for is a only one dropdown menu(selector) because in my dashboard I wan't to be able to select a deployment or a statefulset but not both at the same time.

I've tried at the different side:

1) With prometheus by using a query like this:

 kube_deployment_labels{namespace="$namespace"} or kube_statefulset_labels{namespace="$namespace"}

But in this case I'm not able to extract the labels(could be "deployment" or statefulset")

2) It seems not possible to perform a merge of two template variables in grafana like this:

$deployment,$statefulset

Maybe I've missed something...

Thanks,

Matt

Upvotes: 8

Views: 6689

Answers (1)

Amjad Hussain Syed
Amjad Hussain Syed

Reputation: 1040

I do it by creating two separate variable and give them same label name. Since the label name is same it will only show one drop-down.

https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#basic-variable-options

Upvotes: 0

Related Questions