Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONata - Issue reading multiple Dashboard Variables #295

Open
jan-deulofeu opened this issue Jul 21, 2022 · 3 comments
Open

JSONata - Issue reading multiple Dashboard Variables #295

jan-deulofeu opened this issue Jul 21, 2022 · 3 comments

Comments

@jan-deulofeu
Copy link

jan-deulofeu commented Jul 21, 2022

Hi,

We are having this a global variable (multi value variable), and we are not able to read the actual position of the variable. We are been forced to set the index of the array statically:

Panel Url request: http://localhost:3000/d/h5tWCggVz/app?orgId=1&var-cluster_zone=k8&var-environment_value=int&var-environment_value=nft&editview=templating

Multivalued variable-> environment_value with values (int, nft)

In the JSONata field we can only access to the the values using the array index ($environment_value[0] or $environment_value[1]). We should be able to access to the current value using ${environment_value} or $environment_value.

Do you have any suggestion about how to access to the actual parameter without the need to set the index in the array?

`(
$searchEnvironment := function($cluster, $envirovement) {(
$status := $lookup($.teamDashboards, $cluster).applications[*].environments[name = $envirovement];
)};

$r := $searchEnvironment($cluster_zone[0], $environment_value[0]).canaryStatus ;
)`

Screenshot 2022-07-21 at 09 02 19

Quoting the documentation Dashboard variables are available as JSONata variables, e.g. $instanceName. Since dashboard variables can have multiple values, the JSONata variable is always an array. If your variable contains a single value, you can use $instanceName[0] to index the first value in the array.

Given Dashboards variables are an array, if we are using the variable in a Dashboard Row to loop over the values of a variables, how can we know which index of the array we are in? can we access to the actual iterator? or can we just use the actuakl value accessing to the variables (as in JsonPath) using the variable reference like: ${environment_value}

@ashishamway
Copy link

I am also facing same issue.

@paulinaptf
Copy link

I put a comment with the same problem in another issue. However, this one is exactly my issue.

@gabor
Copy link
Contributor

gabor commented Jun 21, 2024

hi, as some limitations were applied to jsonata in plugin-version v1.3.5 ( see https://github.com/grafana/grafana-json-datasource/blob/main/CHANGELOG.md#v135---2023-04-05 ) for more info, could you try with the current grafana and plugin version, and see if the problem is still actual? thank you!

@gabor gabor moved this to Awaiting Response in OSS Big Tent Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Awaiting Response
Development

No branches or pull requests

4 participants