What Grafana version and what operating system are you using?
Latest Grafana on Windows 11
What are you trying to achieve?
I want to get a dashboard variable display name from a query in a dropdown box.
But the selected value should not be the display name but other part from query result
How are you trying to achieve it?
I see the regex section on the variable settings but don’t know how to use.
Even the online help (provided by the link in the regex) does not help me.
What happened?
Up to now nothing
What did you expect to happen?
From my query I get a resultset like this:
‘ProdA 123’,
‘ProdB 2345’,
‘ProdC 45611’
…
Now the dropdownbox on the dashboard for this variable should show excatly this result as display name / selectable items:
‘ProdA 123’,
‘ProdB 2345’,
‘ProdC 45611’
…
But the selected values shoud be only a part of the dataset (means I need only the number) like this:
‘123’,
‘2345’,
‘45611’
…
This number I need for subsequent mysql queries.
So how to get display name and value separated?
I think the regex field in the variable options should make it, but I don’t know how to create the correct regex to separate display name and value.
@yosiasz: thanks but I don’t know how this can help me.
I don’t get a dataset in key / value pairs.
I get exactly one column:
‘ProdA 123’,
‘ProdB 2345’,
‘ProdC 45611’
…
I think the regex in the variable settings is the right way, correct me if I am wrong.
As you can see here (from [Add variables | Grafana documentation]):
It is mysql database.
But I cannot change the query itself since I myself don’t have acces to the database.
So I have to deal with the result as it is and use the regex option if that is a solution.
BTW:
What if I have access to the database, can I change the query to separate display name from value? (Just to improve my knowledge)