Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 757
Matt Avatar asked Feb 19 '18 15:02

Matt


1 Answers

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

like image 118
Amjad Hussain Syed Avatar answered Oct 16 '22 17:10

Amjad Hussain Syed