Skip to content

JSONata - Issue reading multiple Dashboard Variables #295

@jan-deulofeu

Description

@jan-deulofeu

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Awaiting Response

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions