Variable with Text and Value bug (I assumed)

  • What Grafana version and what operating system are you using?
    Grafana 9.0.5, with RHEL 8

  • What are you trying to achieve?

I want to use the Variable using text and value as per Filter variables with regex | Grafana documentation
I want to use the text instead of the value.
The datasource is Prometheus

  • How are you trying to achieve it?

Instead of showing the value, I need the text of the result of the variable

  • What happened?
    The result of the variable are all the text and values.
    Both of them shown in the result…
    I use snmp exporter to get the ifAlias as text instead of ifName values

  • What did you expect to happen?
    Just the text of ifAlias shown and use in the panel variable.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Below my variable:
    Query: query_result(sort(ifIndex{instance="$instance"} ) )
    Regex: /ifIndex{ifAlias="(?<text>.*)",ifDescr|ifName="(?<value>.*)",instance/g
    That regex is following the URL above in Grafana Documentation.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    Not at all

  • Did you follow any online instructions? If so, what is the URL?

Is it a bug or expected behavior if the datasource is Prometheus?

Regards,
Fadjar Tandabawana

If you want grafana to use the text only then dont provide it key: value, just provide it key

I have the same inquiry. Is there a way to reference the key OR the value depending on how you want to use it?

Example:
I have an API I am querying to retrieve a list of applications along with the application ID. I have a variable that is currently extracting the Application Name as the “text” and the ID as the “value” (Regex: “name”:"(?.)",“description”.“id”:(?[0-9]+),"account). I would like to display the Application Name (text) on the graph panel, but I want to link to the source system using the ID (value), because that is the only way to go to the application’s page in the source system.

http://source-system.mydomain.com/&application=$ApplicationID

Please post sample of your api?

Which part of it do you mean? Sorry…

The data coming from your rest api. Since we dont have access to it :wink:

Of course :slight_smile:

{“name”:“Application1”,“description”:“”,“id”:99999,“accountGuid”:“aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee”},
{“name”:“Application2”,“description”:“”,“id”:12345,“accountGuid”:“aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee”}

So, using a variable and updating it in the dropdown, I would want to see “Application1” on the panel, but make a data link to go to the source app using the id “99999”

1 Like

using infinity plugin

image

Thank you. I am using the JSON API Data source and I am able to extract the data. I need to know if there is a way to reference the “text” OR the “value” depending on what part I need.

So we know that two records pairing is:

  1. text:“Application1” value:99999
  2. text:“Application2” value: 12345

when the drop down on the dashboard changes to Application1, I want to be able to reference the “text” as the name of the panel in the dashboard, but I also want to use the value of 99999 to create a dynamic link to another dashboard using that 99999. Unfortunately the dashboard I am trying to reference does not allow use of the “Application1” as part of the URL, just the ID (i.e. - 99999)