-
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
feat(api)!: Fail log queries when executed on instant query endpoint #13421
feat(api)!: Fail log queries when executed on instant query endpoint #13421
Conversation
A log selector expression is a LogQL expression for returning logs, in contrast to sample expressions, which return metrics. The simplest form of log selector expressions are label matchers, e.g. `{env="prod"}`. This PR changes the behaviour of Loki so it does not allow using a log selector expression when the instant query endpoint `/api/v1/query` is queried. Previously this endpoint allowed these types of log queries, but returns inconsistent results, which where a major cause for confusion. Returning a concise error helps the user understand that they likely selected the wrong query type in Grafana when executing the query. Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
…tant query Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
… as instant query Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 ❤️ (Not super familiar with these parts of Loki yet, so a second pair of eyes would be nice)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with one request:
Please add some details to the upgrade guide for this, I don't think it would be commonly used but if it was, the workaround here would be to do a range query with limit 30
Ok, will do that in a follow up PR. My reason for not putting anything into the UPGRADE guide was, that I thought the upgrade notes were for operational changes. But I agree, it note would be helpful. |
Follow up to #13421 Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
What this PR does / why we need it
Background
A log selector expression is a LogQL expression that returns logs, in contrast to a sample expressions, which returns metrics (samples). The simplest form of log selector expressions are label matchers, e.g.
{env="prod"}
.Change
This PR changes the behaviour of Loki so that the instant query endpoint
/api/v1/query
does not allow sending a log selector expression as query any more. Instead, it returns a status code 400 (Bad Request) with the error message "log queries are not supported as an instant query type, please change you query to a range query type".Why
Previously this API endpoint allowed these types of log queries, but returned inconsistent results, which where a major cause for confusion. Returning a concise error helps the user understand that they likely selected the wrong query type in Grafana when executing the query.
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR