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

Add discarded samples per labelset metric #6464

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Dec 27, 2024

What this PR does:

Add cortex_discarded_samples_per_labelset_total metric to record samples discarded for each configured label set limit.

The labelSetTracker added in #6443 was part of the distributor package. I refactored that and use the same data structure to track label set used by validate metrics.

Note that not all discarded samples reason supports this per labelset metric. Certain reasons such as too many HA groups, ingestion rate exceeded just drops the whole push request instead of an individual series. So in order to get per labelset discarded samples we have to iterate over all series labels, which is possible to have performance impact so I didn't do that in this PR.

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]

Comment on lines 1156 to 1170
updateLabelSetCounter := func(matchedLabelSetLimits []validation.LimitsPerLabelSet, reason string) {
for _, l := range matchedLabelSetLimits {
if c, exists := labelSetCounters[l.Hash]; exists {
c.reasonCounter[reason]++
} else {
labelSetCounters[l.Hash] = &labelsCounter{
reasonCounter: map[string]int{
reason: 1,
},
lbls: l.LabelSet,
}
}
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Could this be a function of the (l *Limits) struct?

Copy link
Contributor Author

@yeya24 yeya24 Dec 28, 2024

Choose a reason for hiding this comment

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

Made it a function of the struct

@alanprot
Copy link
Member

ok.. this is ok i guess as the new metric will only be available if the "per labelset limit" is configure.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 28, 2024
Signed-off-by: Ben Ye <[email protected]>
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