Filtering against a variable while using backend parser for Infinity data source

  • What Grafana version and what operating system are you using?
    Grafana v9.2.2 and Windows 11
  • What are you trying to achieve?
    Filter results of a query to display in a variable only those that are equal to another variable.
  • How are you trying to achieve it?
    Using backend parser for Infinity.
  • What happened?
    Didn’t filter.
  • What did you expect to happen?
    Filter those values that matched the other variable.
  • Can you copy/paste the configuration(s) that you are having problems with?
    tierName == “$tier_A”
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No
  • Did you follow any online instructions? If so, what is the URL?
    No

Welcome @maximilianosalibe

Please share your infinity query and filter you are using.

Sure!
[GET] ${controller_host}/controller/rest/applications/${appName}/nodes?output=JSON
Parsing options, columns:
selector: name (I’ve also tried adding here tierName)
Computed columns, filter:
filter: tierName == “$tier_A”

I am not seeing those options in my infinity. can you share screen capture?

Yes, of course!

can you try this?

tierName == "${tier_A}"

I’ve already tried that, with no results.

can you add ${tier_A} to the title of the dashboard and see what its value is?

I did so in the panel title and it reflects the correct value.

1 Like

wonder if it needs to be

tierName == "${tier_A:csv}"

or you might want to go the infinity UQL filter approach

Hello,

I am trying to achieve pretty much the same.
I would like to use a variable (with __text and __value columns) to filter on the root element of the JSON

Here is my JSON returned by my datasource:

{
    "values": {
        "M-20220630-XXXXXX YYYYYY": [
            "ZZZZZZZZZZZZZZZZ",
            "124124123151243211"
        ],
        "D-20231011-XXXXXX YYYYYYY": [
            "90123182741203098123",
            "AONZCOAUZDAOZINAA",
            "21903ESMLDAXLQSKCA"
        ]
    }
}

I am trying to get one specific element from the “values” object using a variable that I set via a drop down list. but this element contains only one part of the element, so I need a “like” operator here.

Tried the following with the Backend parser (using gjson)

values."${scoping:text}"*

And the following using UQL

parse-json
scope "values"
project kv()
jsonata "*[ '${scoping:text}' in key ][]"

but non of them worked.
FYI when I replace the variable ${scoping:text} with hardcoded values, it works.
I also use this variable in other queries, and it works. Just not in the root selector of infinity queries.