Grafana key value variable For example, a query variable might return a list of server names, sensor IDs, or data centers. com). This works nicely in simple cases, but not if one wants to display user-friendly text in dropdown and use internal var value in queries and human-friendly - in label or title. Is there a way to “map” the values (ie. 3. Sep 23, 2021 · Key => value variable - yes/no, only some SQL (e. Apr 7, 2024 · I’ve encountered a bug in Grafana regarding a variable with key-value pairs. 1 on macOS Sequoia What are you trying to achieve? To get a JSON response from a REST API, store it in a variable and then, while in a panel query, filter out that JSON and get a value for a specific key, depending on another key. When the user selects one of those options I want it to automatically set 4 other variables to hard-coded pre-known values . So I want to set Mar 21, 2021 · Hello everybody, how can i use a custom-variable in a custom variable? I can’t find syntax. 0 of Grafana but unfortunately the Cloudwatch data source does not yet support them. PotgreSQL, MySQL) datasources support it and also Custom variable supports it (make sure you have Grafana version, with support for that - ). Ad hoc filters let you add label/value Feb 11, 2025 · Hi all. 6 running on MacOS, datasource is using the BigQuery datasource from Grafana Labs version 1. Variables set with key value pairs of first name to last name, with multi select and allow all options selected Nov 15, 2021 · You can use key/value variables like the following example: Type = Custom Values separated by comma = var1 : auxvar1,var2 : auxvar2, var3 : auxvar3 The user will just see one picklist: But you'll have the key and the value available in your panels, for example, suppose the user select "var1": ${var:text} = var1 ${var:value} = auxvar1 Learn how to effectively use variables and template variables in Grafana to create dynamic and interactive dashboards. 5 What are you trying to achieve? I have two variables that depends on each other. How are you trying to achieve it? Using a dashboard variable, and then using Infinity Feb 9, 2021 · According to the manual, where custom variables are explained: In the Values separated by comma list, enter the values for this variable in a comma-separated list. How are you trying to achieve it? I am using the Nov 5, 2024 · When defining variables and repeating panels for those variables, it only works when used in simple form - comma separated values. To revisit our earlier example with the servers, it would be painful to have to build a dashboard for every single server you want to monitor. key1 : value1,key2 : value2 - don’t add additional spaces) and then you can use $ {var1:text} to access a key and $ {var1:value} to access value. They can return a list of metrics, labels, label values, query results, or series. For example: Repeating variable var can take values: 1, 2, 3, 4, 5. E. SELECT id AS __value, name AS __text FROM my_table This works fine, but my_table also has a description column, that I would like to use for the description For example, if you have a series of four linked variables (country, Region, server, metric) and you change a root variable value (country), then Grafana must run queries for all the dependent variables before it updates the visualizations in the dashboard. In the resulting dropdown for that variable, the __text is shown, but the variable gets the __value content. When var No, you need to save your relations in some DB first and then query it via hidden variable. I could show all the variables to the user and Jun 2, 2023 · If values dependent variable are not known on the creation stage, or if you want second variable to have more than one value for user to chose from, you'll need to use two variables and some (pseudo-)query with first variable as parameter to generate value of the second one. Add ad hoc filters Ad hoc filters are one of the most complex and flexible variable options available. And I have another variable VAR2 of type Query whiche gets tag values: tag_val0, tag_val1 etc. [date]) AS datetime) Daily : date In my query, I use this variable as follows: SELECT ${Resolution:value} AS ‘time’, However, when I enter the dashboard for the first time, it displays the key (e. v1 → x1 v2 → x2 v3 → x3 Instead of having two variables, I want to have only one, and to have two variables defined when I choose the first variable. These drop-down lists make it easy to update the variable value and thus change the data being displayed in your dashboard. For an introduction to templating and template variables, refer to Templating and Add and manage variables. Proposal: Instead of this sample Nov 1, 2021 · What Grafana version and what operating system are you using? v7. Ideally, I'd have one custom variable containing the comma-separated list of sensor names and user-readable labels, like so: particulate_matter_10_0um_concentration: <10. Jun 1, 2021 · Chaining doesn’t appear to be supported with custom variables, but I was able to use variable key-value pairs in combination with Regex (I’m using InfluxDB) to get something approximating the required functionality. What are you trying to achieve? Setup a variable with a value and a text field so that the text field is displayed but in the dashboard I can reference the value field in other sql. 0µm, particulate Oct 30, 2024 · Let’s explore how Grafana variables work and when, where, and how to use them. When you change the value, the element using the variable will change to reflect the new value. 0) Dashboard panels rows repeated with variable value from system1 (AppDynamics Tiers) and another system have different naming(AWS CloudWatch service name), so we need a lookup based on system1 variable value to another system name. Using query variables, you can write a data source query that returns a list of metric names, tag values, or keys. Is it even possible? Mar 6, 2025 · What happened? Custom Variable Key : value doesn’t seem to be able to store more than one value like a Python dictionary What did you expect to happen? Store multiple values under one key so it would pull those values into the query and display the results in a panel Mains : Mains Incoming, Main 1 Hotel Feed, Mains 2, Kitchen : SDB 6, MCC 6 I want to use variables to repeat a row of graphs related to a set of sensors. Could you give an example of how you'd want to use key/values in variables? Mar 27, 2024 · You need only one variable. You can't do a variable string manipulation in Grafana. Ad hoc filters let you add label/value Feb 29, 2024 · Grafana version v10. 6 What are you trying to achieve? I have a table (my_stats) which contains rows like below ts,src_ip,src_port, dst_ip,dst_port,metric I also have a table (hostnames) for mapping ip to hostname ip,hostname I have a multi-select variable on a dashboard for a user to select the fields they want to aggregate the metric by In Variables Note: Looking for prebuilt Grafana dashboards? Check out our full library of dashboards and more → A variable is a placeholder for a value. The reason for this is that I wanted to put a clean name to the actual value. 4. Explore variable types, use cases, and how to set up template variables for flexible data analysis and visualization. I’ve tried everything possible but unfortunately without success. What are Grafana variables? Variables let you set values that can be passed into a query or transformation. The keys are some human-friendly names and the values (IDs) are used in (Flux) query for filtering. 1. Variable1: FOO,BAR,BAS, Variable2: A MSSQL query that returns a key-value pair such as FOO_ETC:12, BAR_ETC:12 I have a panel that repeats for each value in Variable1, which is used in most queries. We just need to add a new value mapping type: Value Range regular expression Apr 9, 2024 · I need to change the title of a panel based on a variable which the panel repeats over. May 16, 2023 · What Grafana version and what operating system are you using? 9. the panels are not repeated. but it work by value selection manually but required with repeating option and set Jun 13, 2023 · ADX Data Source doesn't produce appropriate Key/Value pairs when used as a variable #591 Sep 21, 2024 · I’m running Grafana on a Linux OS The goal is to use a JSON to pass data to a variable. mysql supports that MySQL | Grafana Labs Aug 21, 2023 · I am trying to create a dashboard variable where the value in the key value pair is an object like a dictionary or list that I can call into elsewhere in the dashboard. Oct 3, 2023 · Use query, that will create this second variable only with orders listed in your original variable. Jun 1, 2023 · Or if I switch the values and keys in the variable around, use “base_devices” as the key to get the corresponding value from variable? Is this possible in Grafana? Add ad hoc filters Ad hoc filters are one of the most complex and flexible variable options available. Use query variables Grafana supports several types of variables, but Query variables are specifically used to query Prometheus. Here is the setup: The first variable is GCP, which is a custom variable with key- May 6, 2024 · I am using a variable called category that is defined as a custom variable using a key:value pair. Closest to this supported feature would be separation of variable name (or key) and value. 3 Windows What are you trying to achieve? I have 2 variables. Mar 26, 2021 · Grafana does support chained variables - where you use the values of one or more existing variables to generate the list of options for a new variable - but that’s done through a data source query, and I don’t think that this is what you want here. Feb 22, 2023 · Referencing Key/Value variable with another variable as the key Grafana Dashboards dashboard-variables gehogan3 February 22, 2023, 8:30pm 1 Aug 9, 2023 · Grafana added support for “key : value” variables Variables: Adds support for key/value mapping in Custom variable by sartaj10 · Pull Request #27829 · grafana/grafana (github. The question is: is it possible to reference a map value by key name in another variable? Assume I have a variable VAR1 of type custom set as map var1:val1 , var2:val2. Are you able to set the key and value to different things without having it predefined in the variables section? Example: Code ran when buttons pressed: Oct 9, 2024 · Grafana Stories — Using Key/value pair variables in dashboard I recently got a query from one of the community member (That I used to take sessions and attend sessions) on fixing their grafana … Key-values format in Variables A Grafana variable can be composed of a key and value to make it possible to join data sets by IDs (key) while displaying user-friendly names (value). You can include numbers, strings, other variables or key/value pairs separated by a colon. InfluxDB doesnt support that. How are you trying to achieve it? Dashboard JSON provided of dummy dashboard. Then your user will be required to input list of orders (as it's done now), and after that tick "Selected" in second variable twice to select all. g Mar 21, 2023 · We have a custom variable where we can set a key:value mapping to override fields in one place for the whole dashboard. 5 on linux What are you trying to achieve? I want to provide a variable (dropdown) at the top of my dashboard which has a bunch of custom options in it. Apr 19, 2023 · 1 Like Key-value variable as a JSON query doesnt work Variable key value regex, using Grafana interpolates in dashboard yosiasz April 19, 2023, 1:10pm 2 andypellew: Feb 15, 2024 · According the Grafana docu (see https://grafana. I have the following example data, as inline data for the infinity datasource [ { "entity":"GOOGL", "price Variables A variable is a placeholder for a value. Mar 12, 2025 · What Grafana version and what operating system are you using? Grafana Cloud (steady) What are you trying to achieve? I want to have a repeating panel for a variable I created. Mar 27, 2021 · Dashboard variables in can only be strings or numbers, which is a limitation in Grafana rather than this plugin. Use key/value pairs (follow syntax from the doc exactly e. In the illustration below, screen 1, the city variable is created with three key-value pairs. In Jan 23, 2023 · What Grafana version and what operating system are you using? Linux v8. I have a custom variable named Resolution with the following key-value pairs: Hourly : CAST(CONVERT(date, a. Apr 30, 2024 · I want to have two variables “Venue” and “SetupName” in grafana, where “Venue” should have dropdown “ABC” and “XYZ”, based on my selection in Venue, “SetupName” should update. IDs) in the query result back to keys so that in panels user can see names instead of raw IDs? For now I have a workaround on the InfluxDB side, but it complicates the queries and Dec 1, 2023 · 1 Grafana doesn't support multifield variables. This way you can chain multiple variables and create complex rules. So I when choose v1 from the droplist, I’ll have two variables; v=v1 and x=x1 Jan 14, 2021 · Key/value dashboard variables are available only for some datasources (where it makes sense). a : foo, b : bar, c : baz Create a new Dec 30, 2020 · What would you like to be added: Create key : value pair variables using a query which returns 2 columns. The variable is created on the dasboardsettings as ‘query’, and is named “testvar”. My initial variable definition was Rules Triggered : rules_triggered, Network Firewall : network_firewall, BOT : bot In the SQL statement, I am referencing the variable using sum(${category:text} However, when doing so Jul 14, 2022 · What Grafana version and what operating system are you using? Grafana v7. When the variables are defined as key : value pairs, the repeat option does not work - i. These drop-down lists make it easy to update Jun 1, 2017 · Grafana has ad-hoc filter variables since v4. 0. For example, if you have a series of four linked variables (country, Region, server, metric) and you change a root variable value (country), then Grafana must run queries for all the dependent variables before it updates the visualizations in the dashboard. SELECT name, value FROM table Why is this needed: Currently, we can create key:value pair variables using variable type Custom. e. You can however chain template variables so that a parent template variable can be passed to a child template variable. Apr 5, 2023 · I have a query type multi-value custom variable several key:value pairs. I know that i can set key/value (map) and later reference key or value by ${var:text} or ${var:value}. Apr 11, 2024 · I have a custom variable called STG which contains the following: ENV1 : 1_1_1_1, ENV2 : 1_1_1_2 This works as intended in most of my queries, however, in one of my queries, I only want to reference the key name (ENV1 … Add ad hoc filters Ad hoc filters are one of the most complex and flexible variable options available. Instead of creating a variable for each dimension by which you want to filter, ad hoc filters automatically create variables (key/value pairs) for all the dimensions returned by your data source query. This allows you to apply filters dashboard-wide. The example below works but May 18, 2025 · What Grafana version and what operating system are you using? 9. 0 - Linux What are you trying to achieve? Selection of variables with key value pairs, where there could be pairs with the same values. for mysql data source SELECT id as `key`, something as Apr 29, 2025 · I'm trying to set up two custom variables in Grafana, GCP and project, with a dependent relationship between them. For example, if you May 17, 2025 · But instead of getting all the row value i am getting only the first row and then modified to Got all the rows but in the dashboard when i try to get the text or value (combine) platinum_clean is the variable name for example $ {platinum_clean:text} it returns the text text correctly when given $ {platinum_clean:value} returns value correctly we have merged the two columns and from the big Oct 13, 2021 · What happened : Key with same values are disabled in the drop down menu for custom template variable (key/Value) What you expected to happen : Key with same values should not be disabled in the drop down menu PFA snaps How to reproduce it (as minimally and precisely as possible) : Try to create custom variable (key : value) with different key names but same value PS : I need a workaround for Aug 31, 2021 · What Grafana version and what operating system are you using? v8. g. How to achieve named variables within query is described in step 4 here: Make sure that the query returns values named __text and __value as appropriate in your query syntax. 3 (252761264e) What are you trying to achieve? I wan to create a key-value variable using data received from JSON API with the JSON API plugin How are you trying to achieve it? I use http… Sep 17, 2024 · I wanted to map the ID:s to names using a built in key value variable, but I cannot get it to work… Instead I had to resort to mapping the values “manually” using the following map () May 20, 2020 · Here we define four key-value pairs to be the set of possible values for our route variable, where the key is the human-readable name of the bus type and the value is the letter corresponding to Apr 12, 2024 · I have a variable called MaxName which has custom values like this: 1: ‘this’, 2: ‘that’ I want to select the values based on another variable called Level, which has values like this: 1, 2 How can I achieve this? T… Jun 7, 2023 · I do see an answer explaining that grafana does a direct substitution for template variables (which I believe is a variable used in a sql editor?), and that’s the reason it errors out: Handle empty variables - #3 by vaishakefi I am trying to follow the thread and try out some solutions. (InfluxDB, Elasticsearch and Prometheus have support). The variable values change as they dynamically fetch options with a data source query. I would like to add a query using the respective value of Variable2 . 5. The Business Variable panel supports this feature in all modes. I saw you can specify key:value pairs in variables of type Custom, but I can't figure out a way to use them for my purpose. By using variables, you can create one generic dashboard and Feb 24, 2022 · Having the possibility to create a query variable with key value pair is a good feature which is already implemented in Custom Variable. This is where I wanted to use key-value var’s to map user-friendly language to column names) Notice the circled 1’s in the next level (Level 2) of the chart (corresponding to “Cohort” chosen in the Mar 27, 2024 · You need only one variable. 2. Query expressions can contain references to other variables and, in effect, create linked Oct 9, 2017 · Current implementation of custom template variable in grafana only expects cofiguration as a comma separated list of values, which is used later in dropdown widget ( component). This variable will be used to modify (filter, visualisation name, timerange, …) a dynamic dashboard. Trying with Dashboard variable with key value pair. Dec 27, 2024 · What Grafana version and what operating system are you using? Grafana v11. The variable v1 postgresql query right now looks like this. com/docs/grafana/latest/dashboards/variables/add-template-variables/#add-a-query-variable ) it should be possible to use special column names __text and __value within queries. Ad hoc filters let you add label/value Sep 2, 2024 · The values you see in the innermost circle - “Sekundar” and “Grundschule” - are values in a column referenced by “School type” (but the column is not called exactly that. This second variable can be used for repetition as expected by Grafana. Steps to reproduce : Create a new custom variable “var1” - set the value to be key value pair. Jul 5, 2024 · Grafana version (v10. However, I’ve tried to enter my variable in multiple formats in the text box of the new variable but it’s always taken as a literal text Oct 19, 2023 · A Grafana variable can be composed of a key and value to make it possible to join data sets by IDs (key) while displaying user-friendly names (value). Variables are displayed as drop-down lists (or in some cases text fields) at the top of the dashboard. e. I would recommend to read Grafana datasources doc to see what is supported/available. sdin dsze qnslulci ncy dufd nkj ruqiawiv xebuqnhg cibf onhme hipmig vzutrf ufjw ghta qkli