Grafana templates

1,394 views
Skip to first unread message

Harmen B

unread,
Mar 9, 2016, 3:10:24 PM3/9/16
to Prometheus Developers
Hello,

I'm trying to get 'templates' working with prom and grafana. These things: http://docs.grafana.org/reference/templating/

It's not really clear what kind of query you need to use, I'm going for 'sum(things) by (name)` to get all the 'name' things. Makes sense? But Grafana keeps showing the error: 'Template variables could not be initialized: undefined' warnings, and the templating pulldown stays empty. Anyone has more success? (it all works fine with a graphite backend)

Tobias Schmidt

unread,
Mar 9, 2016, 3:26:08 PM3/9/16
to Harmen B, Prometheus Developers
Have a look at the Prometheus specific part of the template
documentation http://docs.grafana.org/datasources/prometheus/#templated-queries

It's basically `label_values(name, thing)`. In master there is an
additional option `query_result(<query>)` to execute any kind of
query.
> --
> 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.

Harmen B

unread,
Mar 9, 2016, 3:40:38 PM3/9/16
to Tobias Schmidt, Prometheus Developers
Thanks Tobias,

that works.

viee...@gmail.com

unread,
May 6, 2016, 6:10:59 AM5/6/16
to Prometheus Developers, tob...@gmail.com
Hi ,

I using Grafana 2.6 and Prometheus 0.18. I am using Docker images of these.
My data source is Prometheus.
While creating new variable in templating option , I am using query_result(query) option.

For example , I have used query_result(http_requests_total) but I am getting following error. I have tried couple of different queries but no luck

Template variables could not be initialized: parse error at char 13: could not parse remaining input "(http_requests_"...

What is the proper way to use query_result(query) option.

Tobias Schmidt

unread,
May 6, 2016, 5:46:54 PM5/6/16
to viee...@gmail.com, Prometheus Developers
To my knowledge query_result was only added after 2.6. You have to
upgrade to 3.0 here.
Reply all
Reply to author
Forward
0 new messages