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

feat: Add a new enforced_labels limit #15704

Merged
merged 7 commits into from
Jan 14, 2025
Merged

feat: Add a new enforced_labels limit #15704

merged 7 commits into from
Jan 14, 2025

Conversation

DylanGuedes
Copy link
Contributor

@DylanGuedes DylanGuedes commented Jan 12, 2025

What this PR does / why we need it:
Introduce the new experimental enforced_labels limit.
By default it is empty but when configured, it configures Loki to only accept push requests which streams have all enforced labels.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Jan 12, 2025
pkg/distributor/distributor_test.go Outdated Show resolved Hide resolved
@@ -510,6 +510,16 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
continue
}

if missing, lbMissing := d.missingEnforcedLabels(stream, tenantID, validationContext); missing {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should do this after

lbs, stream.Labels, stream.Hash, err = d.parseStreamLabels(validationContext, stream.Labels, stream)

So we can reuse the lbs instead of implementing fetchLbs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. pushed a commit addressing it, wdyt?

@DylanGuedes DylanGuedes marked this pull request as ready for review January 13, 2025 20:18
@DylanGuedes DylanGuedes requested a review from a team as a code owner January 13, 2025 20:18
Copy link
Contributor

@salvacorts salvacorts left a comment

Choose a reason for hiding this comment

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

LGTM! I think we should test this in dev before merging. wdyt?

@@ -427,32 +427,59 @@ func Test_IncrementTimestamp(t *testing.T) {
}

func Test_MissingEnforcedLabels(t *testing.T) {
limits := &validation.Limits{}
flagext.DefaultValues(limits)
t.Run("missingEnforcedLabels when isolated does what we expect", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what do you mean by isolated here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the function missingEnforcedLabels being invoked in isolation to the rest of the code 😄

Copy link
Contributor

@salvacorts salvacorts Jan 14, 2025

Choose a reason for hiding this comment

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

Ah ok. Maybe there's a better wording for that but not a big deal

Copy link
Contributor

github-actions bot commented Jan 14, 2025

💻 Deploy preview deleted.

@DylanGuedes DylanGuedes merged commit a2c8ec7 into main Jan 14, 2025
62 checks passed
@DylanGuedes DylanGuedes deleted the add-enforce-labels branch January 14, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants