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

discarded samples per labelset metrics for throttle by labelset #6492

Merged

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Jan 8, 2025

What this PR does:

Similar to #6464, but we limited the reason to throttle by max series per labelset only to reduce complexity.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@@ -1048,7 +1064,7 @@ func (d *Distributor) prepareSeriesKeys(ctx context.Context, req *cortexpb.Write
matchedLabelSetLimits := validation.LimitsPerLabelSetsForSeries(limitsPerLabelSet, cortexpb.FromLabelAdaptersToLabels(validatedSeries.Labels))
if len(matchedLabelSetLimits) > 0 && labelSetCounters == nil {
// TODO: use pool.
labelSetCounters = make(map[uint64]*samplesLabelSetEntry, len(matchedLabelSetLimits))
labelSetCounters = make(map[uint64]*samplesLabelSetEntry, len(limitsPerLabelSet))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why now we creating with the limitsPerLabelSet size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm, I copied over the code I had from last PR and I am a bit lost here.
I think you are right the size should be at max matchedLabelSetLimits. I will update the code.

@@ -1201,6 +1229,8 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte

case errors.As(cause, &errMaxSeriesPerLabelSetLimitExceeded{}):
perLabelSetSeriesLimitCount++
// We only track per labelset discarded samples for throttling by labelset limit.
reasonCounter.increment(matchedLabelSetLimits, perLabelsetSeriesLimit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though we are only tracking perLabelsetSeriesLimit, we still wanna have this reasonCounter struct so we can easily add other reasons in the future, right?

Copy link
Member

@alanprot alanprot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM! Thanks

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 8, 2025
Signed-off-by: Ben Ye <[email protected]>
@yeya24 yeya24 merged commit 6b6663b into cortexproject:master Jan 8, 2025
17 checks passed
@yeya24 yeya24 deleted the discarded-samples-labelset-throttle branch January 8, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/distributor lgtm This PR has been approved by a maintainer size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants