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

Unable to use $datasource when creating variables via query #16542

Closed
ldaneliukas opened this issue Apr 12, 2019 · 2 comments
Closed

Unable to use $datasource when creating variables via query #16542

ldaneliukas opened this issue Apr 12, 2019 · 2 comments

Comments

@ldaneliukas
Copy link

ldaneliukas commented Apr 12, 2019

What happened: Created a variable ds of the type datasource with "Include All option" enabled. Then used that variable as the datasource for another variable tier of type query. When I saved the dashboard - the $datasource variable dissapeared from the ds variable. As a result, the $tier variable is displayed the value which was retrieved from the first datasource that was available.

image
image

After saving the dashboard $ds dissapeared and the last (and only) result for the variable is still available:
image

  • Note - Clicking 'Update' on the "Edit Variable" screen still works with an empty datasource. The $ds selection is no longer present when attempting to select a datasource. Other "static" datasource are still there.

What you expected to happen: I expected that the the panels which are repeated for all datasources (works fine), will have different values for the $tier variable as its taken from the datasource that is used for that panel at the time of repeating.

How to reproduce it (as minimally and precisely as possible):

  • Create a variable ds of type datasource with Include All option enabled
  • Create any variable of type query and pick $ds as the datasource.
  • Save the dashboard, close it, re-open it and check the variables.
  • Add a panel that displays the value of $any variable and repeat it for all instnaces of $ds variable

Anything else we need to know?:

Environment:

  • Grafana version: Grafana v6.1.3 (9504db8)
  • Data source type & version: Prometheus 2.6.0
  • OS Grafana is installed on: Docker container
  • User OS & Browser: Chrome on Fedora 29
  • Grafana plugins:
  • Others:
@torkelo
Copy link
Member

torkelo commented Apr 12, 2019

I expected that the the panels which are repeated for all datasources (works fine), will have different values for the $tier variable as its taken from the datasource that is used for that panel at the time of repeating.

This is not supported and likely never will be. Repeating panels will not trigger new template variable queries. Template variable values will be shared for all repeating panels. Only the variable that your repeating by is going to be different. If you have nested variables and repeat using the parent variable, the panels will all have same value for the child variable as Grafana will not evaluate the child variable for every repeat instance.

Create a variable ds of type datasource with Include All option enabled
Create any variable of type query and pick $ds as the datasource.

Multi-valued data sources can only be used in repeat & panels not in as a datasource in other variables. We should add a validation warning for this!

@torkelo
Copy link
Member

torkelo commented Apr 12, 2019

Created a new issue to create a warning for this: #16543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants