-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Implement RequiredNumberLabels
query limit
#8918
Conversation
RequiredNumberLabels
limit
RequiredNumberLabels
limitRequiredNumberLabels
query 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.
[docs team] LGTM
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.
one nit, but LGTM
original := l.CombinedLimits.RequiredNumberLabels(ctx, userID) | ||
requestLimits := ExtractQueryLimitsContext(ctx) | ||
if requestLimits == nil || requestLimits.RequiredNumberLabels == 0 || requestLimits.RequiredNumberLabels > original { | ||
level.Debug(logutil.WithContext(ctx, l.logger)).Log("msg", "using original 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.
This should log the tenant, original & requested limits we compared.
edit: I think all the other limits in this file should do the same, but I'm fine if that's all left for another PR.
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.
Agreed with doing that on a separate PR.
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.
a few nits
pkg/util/querylimits/propagation.go
Outdated
MaxEntriesLimitPerQuery int `json:"maxEntriesLimitPerQuery,omitempty"` | ||
QueryTimeout model.Duration `json:"queryTimeout,omitempty"` | ||
RequiredLabels []string `json:"requiredLabels,omitempty"` | ||
RequiredNumberLabels int `json:"requiredNumberLabels,omitempty"` |
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.
double checking: shouldn't the json here be "requiredNumberLabelMatchers"?
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.
Yeah, agree with this as well.
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.
Done
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.
@DylanGuedes gave a great review, much better than mine!
Co-authored-by: Dylan Guedes <djmgguedes@gmail.com>
@DylanGuedes @owen-d thanks for the review! I believe I've addressed all the pending comments. |
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.
one more nit and then LGTM!
Co-authored-by: Dylan Guedes <djmgguedes@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.
lgtm!
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.
Looks good to me but o have a request for the naming.
@@ -119,13 +128,17 @@ func TestLimiter_RejectHighLimits(t *testing.T) { | |||
MaxEntriesLimitPerQuery: 10, | |||
QueryTimeout: model.Duration(30 * time.Second), | |||
MaxQueryBytesRead: 10, | |||
// In this case, the higher it is, the more restrictive. | |||
// Therefore, we return the query-time limit as it's more restrictive than the original. |
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.
Is this comment correct here?
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.
Yes. See #8918 (comment)
MaxEntriesLimitPerQuery int `json:"maxEntriesLimitPerQuery,omitempty"` | ||
QueryTimeout model.Duration `json:"queryTimeout,omitempty"` | ||
RequiredLabels []string `json:"requiredLabels,omitempty"` | ||
RequiredNumberLabels int `json:"requiredNumberLabelMatchers,omitempty"` |
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've discussed the banking with Steven. We should omit "Matchers" and use minimumLabelsCount
or minimumLabelsNumner
.
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.
**What this PR does / why we need it**: Followup PR for #8918 renaming config. See https://github.com/grafana/loki/pull/8918/files#r1151820792. **Which issue(s) this PR fixes**: Fixes grafana/loki-private#699 **Special notes for your reviewer**: **Checklist** - [ ] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [x] Documentation added - [ ] Tests updated - [ ] `CHANGELOG.md` updated - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/upgrading/_index.md` --------- Co-authored-by: Dylan Guedes <djmgguedes@gmail.com>
What this PR does / why we need it:
As pointed out in #8851, some queries can impose a great workload on a cluster by selecting too many streams.
Similarly to the
RequiredLabels
limit introduced at #8851, here we add a new limitRequiredNumberLabels
to require queries to specify at least N label. For example, if the limit is set to 2, then the query should contain at least 2 label matchers.This limit can be configured per tenant and at query time.
Which issue(s) this PR fixes:
Fixes https://github.com/grafana/loki-private/issues/699
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)CHANGELOG.md
updateddocs/sources/upgrading/_index.md