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

Grafana template variables are transpiled incorrectly #4

Open
Illutax opened this issue Apr 28, 2023 · 0 comments
Open

Grafana template variables are transpiled incorrectly #4

Illutax opened this issue Apr 28, 2023 · 0 comments

Comments

@Illutax
Copy link

Illutax commented Apr 28, 2023

Suppose I have a InfluxQL query

SELECT "mean" FROM "method_timed" WHERE ("environment_name" =~ /^$environment_name$/) GROUP BY "notification_type"

Where $environment_name$ is an Grafana template variable, which is used inside an regex. Currently it is transpiled to

from(bucket: "<bucket_name>")
  |> filter(fn: (r) => r._measurement == "method_timed")
  |> filter(fn: (r) => r._field == "mean")
  |> filter(fn: (r) => r.environment_name =~ /^$environment_name$/)
  |> group(columns: ["notification_type"], mode: "by")
  |> keep(columns: ["_time", "_value", "notification_type"])
  |> sort(columns: ["_time"])

But the filter (r) => r.environment_name =~ /^$environment_name$/ is not valid.

The expected result is: (r) => r.environment_name =~ /^${environment_name:regex}$/, because a template variable should be enclosed by curly braces.

And the :regex prefix is necessary because if the template variable is set to return multiple values it is set as {foo,bar,baz} which is not regex friendly.

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