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

Header does not parse unescaped dashboard variables #62

Open
ChristopherBull opened this issue Apr 22, 2020 · 3 comments
Open

Header does not parse unescaped dashboard variables #62

ChristopherBull opened this issue Apr 22, 2020 · 3 comments

Comments

@ChristopherBull
Copy link

I have a dashboard variable which I refer to in the 'Headers' field:
{Authorization: "api-key $apiKey"}

But Chrome Inspector shows it passing the variable as a string, instead of parsing the value of the variable. Chrome outputs:
authorization | api-key $apiKey

I expect it to parse the variable, i.e:
authorization | api-key the-value-of-my-variable

I can see the variable exists and has the correct value (as you have handily shown a list of variables in the panel edit page).

Variables are correctly parsed for the URL. So looks as if it is specific to parsing the header.

Would be good if there was a preview of the header too.

Grafana version: 6.7.2
AJAX Panel version: 0.0.6 (latest)

@ChristopherBull ChristopherBull changed the title Header does not parse dashboard variables Header does not parsing dashboard variables Apr 22, 2020
@ChristopherBull ChristopherBull changed the title Header does not parsing dashboard variables Header does not parse dashboard variables Apr 22, 2020
@ChristopherBull ChristopherBull changed the title Header does not parse dashboard variables Header does not parse unescaped dashboard variables Apr 22, 2020
@ChristopherBull
Copy link
Author

I managed to get my instance working by using:
{Authorization: 'api-key ' + ctrl.template('$apiKey')}

I was lead to believe that unescaped dashboard variables could be parsed within a string, as I can see an example of that in the screenshot images in your README file.

@ChristopherBull
Copy link
Author

ChristopherBull commented Jul 15, 2020

My previous work-around no longer works with the latest versions of Grafana.

I have a varable in a template called apiKey with a template value of REPLACE-WITH-KEY. I update the variable in the Grafana web UI with an API key (it is still there after refreshing). But when I look at Chrome's inspection view, the AJAX panel is sending REPLACE-WITH-KEY instead of the updated private API key. Presumably because it is getting the template variable value instead of the updated actual variable value.

I do not know how to get the variable value as I cannot find the documentation for ctrl. Please send help.

Grafana version: 7.0.6
AJAX Panel version: 0.0.7-dev

@ChristopherBull
Copy link
Author

This appears to be a joint problem with Grafana and this plugin:

  1. Grafana appears to have an issue whereby variables are not saved/loaded correctly, for example: Hidden constant variables not taking effect when updated grafana/grafana#20600
  2. This plugin does not update the visualisation of the contents for subsequent requests. I have observed several HTTP 401 (unauthorised) errors when my API key could not be read from its variable and the correct associated error was shown in this plugin's panel-as expected (except for Grafana apparently being unable to read the variable). However, with Some Magic™ (examples in the Grafana issue cited above), I managed to get the panel to read the correct value, send the request, and receive a HTTP 200 (OK) request, but this plugin ignored it and did not replace the previous error message in the visualisation. What if there was a server 5xx error request during dashboard load and subsequent requests work? Only the error message would get displayed, as the contents of the panel do not appear to update for subsequent requests.

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

1 participant