Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a display name to a custom variable in Grafana dashboard?

There is an option to create custom variables and give CSV values for them which appear in the drop-down selection of Grafana Dashboard. These variables become the input to the queries which are templatized. Sometimes, the variable values are not readable but they mean something. Example: If a dashboard is displaying stats of a city then the queries would have a condition like city_id: $city_id where $city_id is replaced by the custom variable which represents the city id 12345. Instead of having to display the id (12345), I want to display the names of the cities like Bengaluru, Mumbai, Delhi, etc

like image 542
NitishDeshpande Avatar asked Oct 16 '25 13:10

NitishDeshpande


2 Answers

  • go to Dashboard -> Settings -> JSON Model
  • find templating section and the variables you defined
  • modify the text field for the variable whose display name you want to change enter image description here
like image 199
RY_ Zheng Avatar answered Oct 19 '25 12:10

RY_ Zheng


This option is not available on the dashboard configuration screen. But, if you see the JSON Model of the dashboard and see the templating section there is a list of options where the variables are defined. It has a text and value field. You can modify the text field to set the display name. Save the changes and refresh your dashboard, the changes will be reflected.

like image 28
NitishDeshpande Avatar answered Oct 19 '25 14:10

NitishDeshpande