Reputation: 1077
i am building a couple dashboards using grafana and i found the templating feature to be very useful, however i am monitoring some ec2 instances and getting some metrics from cloudwatch's ec2 namespace, however those use the instanceid as parameter, since the instanceid is not really human readable, which brings me to my question:
Is there any way to have key/value pairs as templating variables for a dashboard? that way people would see the hostname, select it, and the right instanceid would be fed to the panels,
Thanks in advance
Upvotes: 1
Views: 8629
Reputation: 306
If you are using PostgreSQL as source of data(and may be same thing works for other data sources), you can just query:
SELECT hostname AS __text, id AS __value FROM host
And it will do everything else itself
Taken from official docs
Upvotes: 1
Reputation: 7969
Grafana has ad-hoc filter variables since v4.0 of Grafana but unfortunately the Cloudwatch data source does not yet support them. (InfluxDB, Elasticsearch and Prometheus have support).
You can however chain template variables so that a parent template variable can be passed to a child template variable. Here is a demo of that (using Graphite but the principle is the same).
And this Cloudwatch dashboard on Grafana.com also uses this feature:
https://grafana.com/dashboards/590
This is a child template variable (below). The other template variable values get passed into the query for Dimension Value - dimension_values($region, $namespace, $metric, $dimension)
Upvotes: 1