Populating nested Grafana template variables

2,250 views
Skip to first unread message

andrew....@gmail.com

unread,
Aug 15, 2016, 12:34:37 PM8/15/16
to Prometheus Developers
Hi

I have servers divided into groups (development, production, etc.). I have assigned a corresponding 'group' label to my Prometheus time series.

I can easily populate a 'group' drop-down in Grafana by using the query 'label_values(group)', but to get a drop-down of servers belonging to that group I have use a query like 'query_result(node_time{group="$group"})' with a regex of '.*instance="([^"]*)".*'.

Is this the correct approach, or am I missing a more obvious solution?

Regards
Andrew

Tobias Schmidt

unread,
Aug 15, 2016, 1:08:23 PM8/15/16
to andrew....@gmail.com, Prometheus Developers
I'm not aware of a better solution in Grafana. Dynamic datasource selection has been added recently and would benefit from some more improvements. I'd recommend creating an issue on the Grafana repo to make that easier.

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bryce Walter

unread,
Aug 15, 2016, 6:10:52 PM8/15/16
to Prometheus Developers
You would need to set up template variables and have Group as the variable LABEL; then put in your query within the variable settings.

Yosef Yudilevich

unread,
Aug 16, 2016, 4:11:32 AM8/16/16
to Prometheus Developers
amm
please can you put example?
its hard to understand and i need it to a big time
so  say i have
$group   label_values(my_group)
which will give fist drop down

and now i want all the instances in that group in second dropdown
so how to do it?

thanks

Yosef Yudilevich

unread,
Aug 16, 2016, 4:35:42 AM8/16/16
to Prometheus Developers
ok i got it

$my_oslabel_values(os)

$machineslabel_values({os="$my_os"},instance)
Reply all
Reply to author
Forward
0 new messages