Skip to content

Conversation

SungJin1212
Copy link
Member

Add label validations to Prometheus remote write 2.0

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

Checklist

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

@dosubot dosubot bot added the type/feature label Oct 13, 2025
@SungJin1212 SungJin1212 force-pushed the PRW2-add-label-validation branch from 21b09ab to eb0be55 Compare October 14, 2025 02:24
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

I wonder why this validation is applied in convertV2RequestToV1. Isn't the same thing applied for V1 push logic?

We already have labels validation logic in

if limits.EnforceMetricName {
and it enforces metric name, label name and duplicate labels.

lbs := v2Ts.ToLabels(&b, symbols)
// PRW2 spec allows UTF-8.
// c.f. https://prometheus.io/docs/specs/prw/remote_write_spec_2_0/#series-labels
if !lbs.Has(labels.MetricName) || !lbs.IsValid(model.UTF8Validation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to check name validation scheme first? UTF-8 may not be enabled.
Or this validation will be applied later in distributor's push logic

@yeya24
Copy link
Contributor

yeya24 commented Oct 14, 2025

#7043 (comment)

I wonder if this is the right problem. I think the validation logic should apply for both v1 and v2

@SungJin1212 SungJin1212 force-pushed the PRW2-add-label-validation branch from eb0be55 to 0d78022 Compare October 14, 2025 06:53
@SungJin1212 SungJin1212 requested a review from yeya24 October 14, 2025 07:02
@SungJin1212 SungJin1212 force-pushed the PRW2-add-label-validation branch from 0d78022 to 6badbc1 Compare October 14, 2025 07:04
@SungJin1212
Copy link
Member Author

@yeya24
I added empty labels validation logic to the distributor layer.

@SungJin1212 SungJin1212 force-pushed the PRW2-add-label-validation branch from 6badbc1 to a4389c5 Compare October 14, 2025 11:16
@yeya24
Copy link
Contributor

yeya24 commented Oct 14, 2025

Let's update the PR title. Now this change is not specific to PRW2

Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Thx

Copy link
Contributor

@danielblando danielblando left a comment

Choose a reason for hiding this comment

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

Thanks

@danielblando danielblando merged commit 2fed9b7 into cortexproject:master Oct 14, 2025
18 checks passed
@yeya24 yeya24 changed the title PRW2: add label validations Validate empty labels in push Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PRW2 accepts empty metrics instead of rejecting them

3 participants