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

Text box template variable doesn't work properly without a default value #13666

Closed
davewat opened this issue Oct 14, 2018 · 10 comments · Fixed by #13791
Closed

Text box template variable doesn't work properly without a default value #13666

davewat opened this issue Oct 14, 2018 · 10 comments · Fixed by #13791

Comments

@davewat
Copy link
Contributor

davewat commented Oct 14, 2018

Please include this information:

What Grafana version are you using? 5.3.0 via Docker

What datasource are you using? Elasticsearch

What OS are you running grafana on? CentOS 7.4

What did you do? Added new TextBox variable to Dashboard template, and include in metric query

What was the expected result? Variable value would be passed in the Lucene search (like other variables, example with constant attached)

What happened instead? The text of $variablename was passed instead

New Textbox variable is promising, but unable to get it to work - the variable name is passed in the metric query, as opposed to the value that is entered. Screenshots showing contant passed correctly, but textbox variable not passed:

grafana53_contant_works
grafana53_contant_works2
grafana53_textbox_fails
grafana53_textbox_fails2

@torkelo
Copy link
Member

torkelo commented Oct 15, 2018

That is very strange, unable to replicate on v5.3

image

Are you sure you are running v5.3 and not v5.2 ?

@torkelo torkelo added the needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc label Oct 15, 2018
@davewat
Copy link
Contributor Author

davewat commented Oct 15, 2018

Encouraged that it works for you, I re-ran the whole process from scratch with the same failure. Grafana app shows version as: v.5.3.0 (commit: c613a31), (and I'm pretty sure Textbox variable wasn't available in 5.2)

FIX - And then I tested again after dumping my browser's entire cache. That fixed it.

I'm not sure if that should be considered a bug? Assume there was some cached code that was not available in 5.2.3 that was needed by 5.3.0. Possibly need to detect version change and update cached data? My prod instance of Grafana is still 5.2.3 ATM.

Could re-title this as - Must dump browser cache following update. Otherwise, this can be closed.
Thanks!

@bolek2000
Copy link

bolek2000 commented Oct 17, 2018

I have the same problem. Browser cache clear doesn't help here. I had the case where in one Dash the variable was detected as a variable an in another dash not (in the same browser=Chromium). After updating to 5.3.1 the problem is in both dashboards, also in the one that worked before with 5.3
Also tested with Firefox, same problem.

@bolek2000
Copy link

bolek2000 commented Oct 18, 2018

I found out, that this problem is present, if I have the default value of the text box empty (what we need) and then add the variable to the where clause of a metric. In the first place I get "No data" and the Query Inspector shows pathlevel1" =~ /$freetext/. Then when I type in the first text in the box and hit reload of the webpage then the filter is noticed as a variable and I get the data I expected.
From then on it seems to work, even though the variable doesn't turn blue in the metrics edit tab. But in another Dash it does turn blue. So there seems to be something weird with noticing the variable as a variable. Note that we need to use /$freetext/ not /^$freetext$/ , because we want to have an empty default that matches '.*' in regexp. /^$freetext$/ actually does turn blue in the metrics edit tab. (I use Ubuntu 16.04 with latest Chromium)

@bolek2000
Copy link

bolek2000 commented Oct 18, 2018

Later on I saved the dashboard again and now the variable also turned blue, where it wasn't before ?? So the point is: when I have text in the box and I press Reload page then the variable is recognized. When I empty the box and press Reload it turns white again in the metrics edit tab and I get "No data".

@marefr marefr changed the title 5.3.0 Template Bug - Textbox variable used in metric query is not replaced with value. Actual variable name is passed instead. Text box template variable doesn't work properly without a default value Oct 18, 2018
@marefr marefr added type/bug area/dashboard/templating and removed needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc labels Oct 18, 2018
@marefr marefr added this to the 5.3.2 milestone Oct 18, 2018
@marefr
Copy link
Contributor

marefr commented Oct 18, 2018

@bolek2000 confirmed that text box template variable doesn't work properly when a default value is not provided. Thank you!

Demo of behavior here

@davewat
Copy link
Contributor Author

davewat commented Oct 22, 2018

This PR will resolve the on empty value issue (on empty is not the same as default): #13752, but it doesn't solve this specific bug, just adds additional capability.

@marefr
Copy link
Contributor

marefr commented Oct 23, 2018

@davewat thanks. However we'll need to include a fix for this bug in patch release so we're going to merge #13791 first and your PR would continue to target a different issue.

@davewat
Copy link
Contributor Author

davewat commented Oct 23, 2018

Thanks @marefr - makes sense to fix the bugs first! I'll resync with master after.

marefr added a commit that referenced this issue Oct 23, 2018
@avlitman
Copy link

Hi I hit the same issue, was the fix implemented in one of the versions?

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

Successfully merging a pull request may close this issue.

5 participants