-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Optimize empty filter queries #1792
Comments
We should also support |
…oesn't contains a filter. The query is not really rewritten and the stringer func still returns the correct original query. However the `Filter` func of the `Expr` returns nil which what is being checked when splitting queries in the frontend and also what is being used in the memchunk. see https://github.com/grafana/loki/blob/master/pkg/querier/queryrange/roundtrip.go#L81 and https://github.com/grafana/loki/blob/master/pkg/chunkenc/memchunk.go#L614 Fixes grafana#1792 Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
* Optimize filter queries such as `{label="foo"} |~ "" |~ ".*" |= ""` doesn't contains a filter. The query is not really rewritten and the stringer func still returns the correct original query. However the `Filter` func of the `Expr` returns nil which what is being checked when splitting queries in the frontend and also what is being used in the memchunk. see https://github.com/grafana/loki/blob/master/pkg/querier/queryrange/roundtrip.go#L81 and https://github.com/grafana/loki/blob/master/pkg/chunkenc/memchunk.go#L614 Fixes #1792 Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com> * Add missing tests with combination of empty or regex. Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com> * Review feedback. Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Let's say you have this It only works when the search is not empty but when you enter in the Grafana dashboard, it is empty and the query fails. @slim-bean is there any way to get it working ? |
I've been struggling with this. I use a |
If a query like:
{label="foo"} |= ""
or{label="foo"} |~ ""
these should be optimized to{label="foo"}
You might ask why would someone do this? When creating a dashboard with a log panel you might want to create a text variable on the dashboard which could be used in the filter expression like so:
{label="foo"} |~ "$searchVar"
If the user leaves this filter blank it ends up sending the query as
{label="foo"} |~ ""
The text was updated successfully, but these errors were encountered: