Can I simulate Grafana tempate variable select drop-down to behave like HTML Select so that displayed value can be different from what is actually sent? Example: <option value="3e9aca6e9b93">i-007ecadde53224a1a</option>
I don’t think this is possible, but now is a great time to file a feature request about variables, since we are currently looking at how to improve this feature for an upcoming minor release.
Say we have EC2 instances and we need to monitor them, so Node Exporter is running on each Instance.
Prometheus Service Discovery is configured to get these instances registered as targets.
Using Node Exporter Dashboard (1860) shows a Host drop-down where one can see nodenames as hexadecimal numbers. Such numbers are not convenient and it would be better to substitute them with say Instance Id or IP address.
That’s why I thought it would be nice to configure it as HTML Select so a form posts nodenames while user is presented with Instance Id or IP address.
There might be some other way to achieve this changing a dashboard, but in my case, if I configure it to show Instance Id by altering "query": "label_values(node_uname_info{job=~\"$job\"}, nodename)", to label_values(node_uname_info{job=~\"$job\"}, instance) I can get Instance Ids shown, but no graphs are displayed. Maybe I need to do some renaming in Prometheus… Please advice
Another option is a query that can create a key/value variable. The query should return two columns that are named __text and __value . The __text column value should be unique (if it is not unique then the first value is used). The options in the dropdown will have a text and value that allows you to have a friendly name as text and an id as the value. An example query with hostname as the text and id as the value:
SELECT hostname AS __text, id AS __value FROM host
So just create proper PostgreSQL table with the right data. Or check Grafana doc of used datasource - maybe it is supported.