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

InfluxDB: Regression interpolating variables in code editor - single variables being escaped in 10.2.3, but not in 10.2.2 #80242

Closed
gtk-grafana opened this issue Jan 9, 2024 · 8 comments · Fixed by #80971
Assignees
Labels
datasource/InfluxDB internal for issues made by grafanistas

Comments

@gtk-grafana
Copy link
Contributor

@todo

          I don't think the issue is limited to regex values. I'm getting the same/similar error with a variable used for a simple exact match. There seems to be an escaping mismatch between encoding and decoding.

I have a query

SELECT "level_name", "message", "file", "line", "exception", "stacktrace" FROM "3m"."php_log" WHERE "environment" = '$Environment' AND "hostname" = '$Host' AND "request_id" = '$RequestID' AND $timeFilter

which gets sent as JSON like

SELECT \"level_name\", \"message\", \"file\", \"line\", \"exception\", \"stacktrace\" FROM \"3m\".\"php_log\" WHERE \"environment\" = 'acceptance' AND \"hostname\" = 'www\\.example\\.com' AND \"request_id\" = 'bbb43433dfb840fe8c58b88c7577d59a' AND $timeFilter

The hostname here isn't (un)escaped properly.

influxdbBackendMigration = false didn't help, but downgrading to 10.2.2 did

Not sure it's the same as or related to #77465, since that one mentions an issue when upgrading from 10.1.x, while it's working for me with 10.2.2

Originally posted by @pprkut in #80003 (comment)

@grafanabot
Copy link
Contributor

@gtk-grafana please add one or more appropriate labels. Here are some tips:

  • if you are making an issue, TODO, or reminder for yourself or your team, please add one label that best describes the product or feature area. Please also add the issue to your project board. 🚀

  • if you are making an issue for any other reason (docs typo, you found a bug, etc), please add at least one label that best describes the product or feature that you are discussing (e.g. area/alerting, datasource/loki, type/docs, type/bug, etc). Our issue triage doc also provides additional guidance on labeling. 🚀

Thank you! ❤️

@gtk-grafana
Copy link
Contributor Author

This is a duplicate of #79692.

@gtk-grafana gtk-grafana closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
@gtk-grafana
Copy link
Contributor Author

gtk-grafana commented Jan 10, 2024

Reopening: I think there's actually 3 problems here: I've identified that the backend migration is the cause for breaking any influx query using a single value template variable that is unescaped: using = or !=.

Only impacts template variables containing special chars that will be escaped
$url = 'http://example.com/test.php'

SELECT * FROM "disk" WHERE ( "device”::host = '$url') AND $timeFilter
^broken by enabling influxdbBackendMigration

But regex works as expected
SELECT * FROM "disk" WHERE ( "device"::tag =~ /^'$url'$/) AND $timeFilter

This doesn't appear to be the issue reported in #79692 because that issue reported showing "No Data" but this incorrect escape of the variable on backend mode returns an error in the panel instead.

So new categorization:
#80003 Template variables containing '/' are not properly escaped by the query builder
#79692 Still investigating/trying to reproduce
#80242 Single value template variables, when used in influx code editor are not properly being escaped.

@pprkut This fits the use case you provided exactly, except that I cannot reproduce this being fixed by reverting to 10.2.2, I can only "fix" this by disabling the feature flag. I tested on main/10.2.2/10.2.3 and saw the same behavior. Working when feature flag disabled, but broken when enabled.

Can you confirm if you saw "No Data" or an error in the panel?

@gtk-grafana gtk-grafana reopened this Jan 10, 2024
@pprkut
Copy link

pprkut commented Jan 10, 2024

My queries weren't made using the visual code editor, but written by hand. Maybe that's the difference? Or maybe specific to the table panel? I didn't see it happening with other panel types.
What I can say is that I downgraded two separate instances to 10.2.2 and it fixed all such issues there, without changing the config. I still have a couple 10.2.3 instances I can compare with though

@gtk-grafana
Copy link
Contributor Author

The flag is enabled by default in 10.2.3, so reverting to 10.2.2 without any other config change will change the value of the feature flag, so that makes it more difficult to see if the issue is resolved by the version or the feature flag.

@pprkut
Copy link

pprkut commented Jan 10, 2024

Ah, so I should test 10.2.2 with influxdbBackendMigration = true to see if the issue appears again? And just to be sure, I would add that in the [server] section?

@gtk-grafana
Copy link
Contributor Author

Yup! It should go in the in the [feature_toggles] section.

@itsmylife itsmylife self-assigned this Jan 16, 2024
@pprkut
Copy link

pprkut commented Jan 18, 2024

@gtk-grafana Sorry, took a bit but you were right. It's influxdbBackendMigration after all. 10.2.3 with it disabled works, and 10.2.2 with it enabled fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasource/InfluxDB internal for issues made by grafanistas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants