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

Adds new metric for dropped samples in ingester #4503

Conversation

pedro-stanaka
Copy link
Contributor

@pedro-stanaka pedro-stanaka commented Sep 30, 2021

What this PR does: As described in #3954, this PR adds a new metric distributor_discarded_samples_total to represent
the number of dropped samples due to relabeling configuration.

Which issue(s) this PR fixes:
Fixes #3954

Checklist

  • Tests updated
  • Documentation added (N/A ?)
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pedro-stanaka pedro-stanaka force-pushed the feature/metric-relabel-new-metric-droped-samples branch from 6f29446 to cba3971 Compare October 1, 2021 07:03
Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Thanks for the PR; I think there are a number of unnecessary changes, or if they are necessary they should go in a different PR.

A good cross-check is to make sure all changes are explained in the commit message.

pkg/distributor/distributor.go Outdated Show resolved Hide resolved
pkg/distributor/distributor.go Show resolved Hide resolved
pkg/distributor/distributor.go Outdated Show resolved Hide resolved
pkg/distributor/distributor_test.go Outdated Show resolved Hide resolved
pkg/distributor/distributor_test.go Outdated Show resolved Hide resolved
pkg/util/validation/validate.go Outdated Show resolved Hide resolved
@pedro-stanaka pedro-stanaka force-pushed the feature/metric-relabel-new-metric-droped-samples branch from 07b6257 to 740296a Compare October 1, 2021 20:45
@pedro-stanaka
Copy link
Contributor Author

@bboreham @alvinlin123 anything else I should be doing here? Can I have further feedback on the PR?

@pedro-stanaka pedro-stanaka force-pushed the feature/metric-relabel-new-metric-droped-samples branch 2 times, most recently from c45ca83 to 9a28d7c Compare October 14, 2021 10:24
@pedro-stanaka pedro-stanaka force-pushed the feature/metric-relabel-new-metric-droped-samples branch 2 times, most recently from 3c1a0b8 to 847d6c6 Compare November 3, 2021 06:44
@pedro-stanaka
Copy link
Contributor Author

Lint output:
image

test output:
image

@pedro-stanaka pedro-stanaka force-pushed the feature/metric-relabel-new-metric-droped-samples branch from 847d6c6 to 459dce2 Compare December 1, 2021 08:20
Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Sorry I let this languish for a while.
Insisting on __name__ is optional -

f.BoolVar(&l.EnforceMetricName, "validation.enforce-metric-name", true, "Enforce every sample has a metric name.")

so please don't add more checks for __name__. Just check whether any labels remain.

@@ -637,6 +637,14 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co

if mrc := d.limits.MetricRelabelConfigs(userID); len(mrc) > 0 {
l := relabel.Process(cortexpb.FromLabelAdaptersToLabels(ts.Labels), mrc...)
if len(l) == 0 {
// all labels are gone, therefore the __name__ label is not present, samples will be discarded
Copy link
Contributor

Choose a reason for hiding this comment

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

remove mention of __name__

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -651,7 +659,12 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co
removeLabel(labelName, &ts.Labels)
}

if len(ts.Labels) == 0 {
if len(ts.Labels) == 0 || wasNameLabelRemoved(ts.Labels) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't look at __name__.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, done.

@pedro-stanaka
Copy link
Contributor Author

I changed as suggested, I think this is finally good to go. Please let me know if I should do anything else. On my machine, linting and tests are passing.

…ow of distributor

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
…rom other test runs

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
@pedro-stanaka pedro-stanaka force-pushed the feature/metric-relabel-new-metric-droped-samples branch from 50d2281 to c29bd27 Compare December 14, 2021 07:30
@pedro-stanaka
Copy link
Contributor Author

@bboreham sorry for the endless ping, but I just want to make sure you get notifications. I implemented your last comments a while ago, checking back to see if this is good to go.

Copy link
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@pedro-stanaka
Copy link
Contributor Author

@alvinlin123 can you please recheck as well so we can merge this? I am going to do yet another rebase.

@alvinlin123 alvinlin123 merged commit dd698bc into cortexproject:master Jan 3, 2022
alvinlin123 pushed a commit to ac1214/cortex that referenced this pull request Jan 14, 2022
* Adding test case for dropping metrics by name to understand better flow of distributor

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Adding test case and new metric for dropped samples

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Updating CHANGELOG with new changes

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Fixing linting problem on distributor file

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Reusing discarded samples metric from validate package

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Compare labelset with len() instead of comparing to nil

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Undoing unnecessary changes on tests and distributor

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Small rename on comment

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Fixing linting offenses

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Reseting validation dropped samples metric to avoid getting metrics from other test runs

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Resolving problems after rebase conflicts

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Registering counter for dropped metrics in test

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Checking if user label drop configuration did not drop __name__ label

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>

* Do not check for name label, adding new test

Signed-off-by: Pedro Tanaka <pedro.stanaka@gmail.com>
Signed-off-by: Alvin Lin <alvinlin@amazon.com>
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.

Add a metric to track samples dropped in distributor by metric_relabel
3 participants