Hello,
I am facing some html/regex escaping related bug when using the regex string .+
with template variables.
In Template Editor:
While using label_values({stack=~“$stack”}, environment) in the template editor, if the $stack template variable contains “.+” regex, then the label_values fails to retrieve any values. The value sent in the http API call to Prometheus replaces the stack=~"$stack"
with stack%3D~%22.%22
(Note the missing escape value for +
).
Using query_result also fails to retrieve values, replacing the stack=~"$stack"
with stack%3D~%22.%22
(Note the missing escape value for +
).
In Graph Panels:
The “.+” regex used as the value to a constant template variable seems to work correctly sometimes and not work other times - when the template variable is used in graph panels, etc. When it does not work, the value sent in the http API call to Prometheus replaces the stack=~"$stack"
with stack%3D~%22.%22
(Note the missing escape value for +
).
The “.+” regex autogenerated (when setting it as the custom value for the ALL option) ALWAYS works correctly. The http API call to Prometheus replaces the environment=~"$env"
(when env is selected as ALL) with environment%3D~%22.%2B%22
(Note the present escape value of %2B for +
).
see this captured request from a single graph panel:
https://my-dashboard-dev/api/datasources/proxy/49/api/v1/query_range?query=collectd_cpu_percent%7Bapplication%3D%22MPCS%22%2Cstack%3D~%22.%22%2Cenvironment%3D~%22.%2B%22%7D&start=1502816412&end=1502817312&step=10
with the template variables being:
Everywhere:
Manually typing in “.+” instead of “$stack” ALWAYS works.
Therefore, the bug seems to be in replacing/interpreting the value of the template variable when its value is a regex. Since the custom value option for ALL does not face this issue, I suspect the bug is in variable processing rather than in HTML escaping.
Any thoughts if this really is a bug? Any ideas on a temporary workaround, while I wait for a long term fix?