grafana / influxdb-flux-datasource

Grafana datasource plugin for Flux (InfluxDB)
Apache License 2.0
51 stars 21 forks source link

Wrong variable expansion format #13

Closed zarbis closed 5 years ago

zarbis commented 5 years ago

If when trying to use variables in queries, they are expanded in format that Flux doesn't expect, even if those variables were defined with Flux query themselves.

For example, if I use it to filter:

filter(fn: (r) =>
r.source =~ $source AND
...)

Variable will be expanded into {foo,bar,baz} while Flux expects Go-style regex like /^(foo|bar|baz)$/.

Also single choice variable will be expanded without double quotes, which also breaks Flux query. One cannot just blindly wrap variable in quotes themselves "$source" since if this variable has multiple/all checkboxes - it will break Go-style regex. Not sure how to deal with this one.

Grafana: 5.4.0 Flux Datasource: 5.2.6

nikolay-t commented 5 years ago

I don't think the suggested change is necessary, because you can control how Grafana embeds variable using :pipe suffix, like this:

r.host =~ /^${host:pipe}$/
zarbis commented 5 years ago

@nikolay-t yeah, sure you can, but does "only working version" not qualify for sensible default?

davkal commented 5 years ago

Agreed on using pipe as default.