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

Global variable loses value upon dashboard refresh #23841

Closed
jericvizmanos opened this issue Apr 24, 2020 · 6 comments · Fixed by #25698
Closed

Global variable loses value upon dashboard refresh #23841

jericvizmanos opened this issue Apr 24, 2020 · 6 comments · Fixed by #25698
Labels
area/dashboard/templating prio/high Must be staffed and worked on either currently, or very soon, ideally in time for the next release. type/bug
Milestone

Comments

@jericvizmanos
Copy link

What happened:
Global variable loses its value after refreshing the dashboard.

What you expected to happen:
After refreshing the dashboard, the values should also get passed.

Before:
Screen Shot 2020-04-23 at 5 11 24 PM

After refreshing the dashboard:
Screen Shot 2020-04-23 at 5 11 31 PM

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

  1. Disable HTML sanitization
  2. Create a Dashboard > Choose text as visualization
  3. Select HTML and enter "${__dashboard.name}"
  4. Give the dashboard a name so the value gets pulled into the ${__dashboard.name}
  5. Refresh the dashboard (upper right of the screen) see that it doesn't pull the value itself and reverts back to "${__dashboard.name}"

Issue is specific to global variables. I tested this out on the dashboard variables and they are working as intended.

@jericvizmanos jericvizmanos changed the title Global variable loses value upon dasbhoard refresh Global variable loses value upon dashboard refresh Apr 24, 2020
@hugohaggmark
Copy link
Contributor

@jericvizmanos could you provide the following so our investigation goes smoother:
Environment:
Grafana version:
Data source type & version:
OS Grafana is installed on:
User OS & Browser:
Grafana plugins:
Others:

@hugohaggmark hugohaggmark added needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc type/bug and removed needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc labels Apr 24, 2020
@hugohaggmark
Copy link
Contributor

I took a quick look at this on master and it seems global variables like org and dashboard are cleared every time we call updateIndex (when we refresh for instance) in templateSrv here:

this.index = this._variables.reduce((acc, currentValue) => {

@hugohaggmark
Copy link
Contributor

Related #25359

@allomorphy
Copy link

Hi @hugohaggmark,

Sorry to abuse this thread. Just would appreciate a heads-up before going into what will probably be a deep hack to provision a single template of dashboards to Teams (Organizations) and their users.

Since I did not receive any response to this plea: #21071 (comment)

Is there anything you could suggest that is orthodox in the FOSS Grafana before I cross over to the black magic ;-)

Many thanks and best wishes,
Eric

@hugohaggmark
Copy link
Contributor

Hi @hugohaggmark,

Sorry to abuse this thread. Just would appreciate a heads-up before going into what will probably be a deep hack to provision a single template of dashboards to Teams (Organizations) and their users.

Since I did not receive any response to this plea: #21071 (comment)

Is there anything you could suggest that is orthodox in the FOSS Grafana before I cross over to the black magic ;-)

Many thanks and best wishes,
Eric

Hi @allomorphy we're looking into providing global/resusable variables for Grafana as first-class citizen.

I can't say or promise when this work will be done but we've started discussions. As part of the team responsible for migrating the existing variable system to our new platform, my advice to you is that this is one of our most complex areas with lot's of special cases so be patient when entering this magical world :)

All the best

@torkelo torkelo added this to the 7.1 milestone Jun 11, 2020
@torkelo torkelo added the prio/high Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Jun 11, 2020
@allomorphy
Copy link

@hugohaggmark @torkelo 💪
We would love to help test. ❤️
Strangely for a health/wellness non-profit, most of our users are high-flying engineers.

(We will hold off then on our own black magic and look forward to your commits).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard/templating prio/high Must be staffed and worked on either currently, or very soon, ideally in time for the next release. type/bug
Projects
None yet
4 participants