-
What Grafana version and what operating system are you using?
Using Grafana 9.4.7, windows 10 -
What are you trying to achieve?
In the configuration of my Infinity datasource plugin, I am trying to use dashboard variables.
Here is my JSON that I am getting when I call my JSON API.
{
"values": {
"M-20220630-XXXXXX YYYYYY": [
"ZZZZZZZZZZZZZZZZ",
"124124123151243211"
],
"D-20231011-XXXXXX YYYYYYY": [
"90123182741203098123",
"AONZCOAUZDAOZINAA",
"21903ESMLDAXLQSKCA"
]
}
}
What I am trying to do is getting one specific element from the “values” object using a variable (called “scoping” in my case) that I set via a drop down list.
But my variable contains only one part of the element, lets say I selected “D-20231011”.
So I need a “like” operator here that will allow me to get the object “D-20231011-XXXXXX YYYYYYY”, then all its content.
"90123182741203098123",
"AONZCOAUZDAOZINAA",
"21903ESMLDAXLQSKCA"
- How are you trying to achieve it?
When I try the following with a hardcoded substring
parse-json
scope "values"
project kv()
jsonata "*[ $contains(key, 'D-20231011-CADRAGE V1') ][]"
it works fine and I get
“D-20231011-XXXXXX YYYYYYY”
But when I try with the variable, like so
parse-json
scope "values"
project kv()
jsonata "*[ $contains(key, ${scoping:text}) ]"
I simply get all the objects in the “values”, nothing gets filtered.
Can anyone please help me point to the right direction ?