Grafana tempate variable select drop-down to send different value

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>

The root of my problem can be seen here: https://stackoverflow.com/questions/62284573/how-to-rename-host-values-in-grafana-dashboard

Can you tell us more about your use case?

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.

Sure!

  • 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

Some datasources offer that. For example PostgreSQL: https://grafana.com/docs/grafana/latest/features/datasources/postgres/#templating

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.

Filter and modify using named text and value capture groups