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

Improve validation metrics for discarded samples and exemplars #6218

Merged

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Sep 18, 2024

What this PR does:

In Distributor's validation logic, we currently update DiscardedSamples metric when there is no label.
However, it doesn't count native histogram samples, only normal samples. It doesn't track discarded exemplars or track it in a wrong way https://github.com/cortexproject/cortex/blob/master/pkg/distributor/distributor.go#L898

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]

Signed-off-by: Ben Ye <benye@amazon.com>
Copy link
Member

@friedrichg friedrichg left a comment

Choose a reason for hiding this comment

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

Probably needs a test 😁

Copy link
Member

@CharlieTLe CharlieTLe left a comment

Choose a reason for hiding this comment

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

Should we create a new metric for discarded histograms? Perhaps add a new label to this metric called type like we do in

d.incomingSamples.WithLabelValues(userID, sampleMetricTypeHistogram).Add(float64(numHistogramSamples))

@yeya24
Copy link
Contributor Author

yeya24 commented Sep 19, 2024

@CharlieTLe I think we can add that but it will be a big change. Probably all the DiscardedSamples code we need to separate float and native histogram samples.

We can create a separate issue to discuss and track that.

Signed-off-by: Ben Ye <benye@amazon.com>
@pull-request-size pull-request-size bot added size/M and removed size/S labels Sep 19, 2024
@yeya24
Copy link
Contributor Author

yeya24 commented Sep 19, 2024

@friedrichg Updated unit tests

require.Equal(t, testutil.ToFloat64(ds[0].validateMetrics.DiscardedSamples.WithLabelValues(validation.DroppedByRelabelConfiguration, id)), float64(1))
require.Equal(t, testutil.ToFloat64(ds[0].validateMetrics.DiscardedExemplars.WithLabelValues(validation.DroppedByRelabelConfiguration, id)), float64(2))
require.Equal(t, testutil.ToFloat64(ds[0].receivedSamples.WithLabelValues(id, "float")), float64(1))
require.Equal(t, testutil.ToFloat64(ds[0].receivedSamples.WithLabelValues(id, "histogram")), float64(0))
Copy link
Member

Choose a reason for hiding this comment

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

Should we test ingesting a native histogram and see it be discarded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in latest commit

Signed-off-by: Ben Ye <benye@amazon.com>
@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 20, 2024
Copy link
Member

@friedrichg friedrichg left a comment

Choose a reason for hiding this comment

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

Thanks!

@yeya24 yeya24 merged commit d829d65 into cortexproject:master Sep 20, 2024
16 checks passed
@yeya24 yeya24 deleted the improve-validation-metric-no-label branch September 20, 2024 21:48
Copy link
Member

@CharlieTLe CharlieTLe left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants