-
Notifications
You must be signed in to change notification settings - Fork 816
Reject small subquery step size in query frontend #5323
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
Conversation
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
pkg/querier/tripperware/subquery.go
Outdated
) | ||
|
||
var ( | ||
ErrSubQueryStepTooSmall = "exceeded maximum resolution of %d points per timeseries in subquery. Try decreasing the step size of your subquery" |
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.
I think you meant to recommend "increasing" the step size? or decreasing the "number of steps"?
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.
Good catch. I updated it to increasing the step size
.
{ | ||
name: "two subqueries within functions", | ||
query: "sum_over_time(up[60m:]) + avg_over_time(test[5m:1m])", | ||
maxStep: 10, | ||
defaultStep: time.Second, | ||
err: httpgrpc.Errorf(http.StatusBadRequest, ErrSubQueryStepTooSmall, 10), | ||
}, |
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.
Could we also add a test for two subqueries that's within the step limit?
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.
Thanks. Added another test case.
Signed-off-by: Ben Ye <[email protected]>
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.
Thank you! LGTM
THANKS! LGTM |
What this PR does:
In Prometheus, there is a step size check to make sure we don't have too many samples for a series for range query because it takes step and range parameters https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go#L503.
However, there is no such check for subquery, which makes subqueries to have very large steps such as
up[30d:1s]
. This could easily OOM kill queriers.This pr adds the same step size check in QFE to reject such queries.
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]