What are ScopedVars and what are they used for?

I do not find any relevant documentation on this subject. I think it is like dashboard variables but declared inside panel code. I am not sure.

The definition of the interface is:

export interface ScopedVar<T = any> {
  text: any;
  value: T;
  [key: string]: any;
}

export interface ScopedVars {
  [key: string]: ScopedVar;
}

If the variable is the key of ScopedVars, what text of ScopedVar is for ?
How are used other keys ([key: string]: any;) of ScopedVar ?

Thank you.

1 Like

I just run into the same question.
Here is a use case that I found…When you use template variables you can choose the option muti-value that allow to select multiple values in the dropdown list.

Lets say your template variable is the geolocation of your instances that your are monitoring.

Then you have a panel that you would like to display the same metric for each of the selected values in your template variable (not all in the same panel).

Lets say response time for all your instances with the geolocation values you have selected.

Now you can create a Row for your panel and you can set the option Repeat For. This option will have a dropdown with any template variable you have defined in your dashboard, so you can choose the one you would like to display your filtered metric for.

In this scenario you can select your Repeat For: geoloacation and this will create the same panel for each geolocation selected. And it would only display the instances that belong to that geolocation.

1 Like