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: Map streams to scopes and add per-scope ingestion block. #15561

Closed
wants to merge 37 commits into from

Conversation

DylanGuedes
Copy link
Contributor

@DylanGuedes DylanGuedes commented Dec 30, 2024

What this PR does / why we need it:

  • Add to Loki the capability of recognizing ingestion for the same tenant as having different scopes. This is done through a configurable label, which is a runtime limit config.
  • Add a form of block ingestion based on its scope. It will look into the label configured by the bullet above.

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 5, 2025
Copy link
Contributor

github-actions bot commented Jan 5, 2025

@DylanGuedes DylanGuedes changed the title feat: Add per-scope ingestion block. feat: Map streams to scopes and add per-scope ingestion block. Jan 15, 2025
@DylanGuedes DylanGuedes marked this pull request as ready for review January 15, 2025 18:14
@DylanGuedes DylanGuedes requested a review from a team as a code owner January 15, 2025 18:14
@@ -3941,6 +3941,25 @@ otlp_config:
# CLI flag: -limits.block-ingestion-status-code
[block_ingestion_status_code: <int> | default = 260]

# Block ingestion until the given time for the given policy. Pushes will be
# assigned to a policy based on the stream matcher configuration. Experimental.
[block_policy_ingestion_until: <map of string to Time>]
Copy link
Contributor

@JStickler JStickler Jan 29, 2025

Choose a reason for hiding this comment

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

Are there defaults for any of these settings? (even if the default is nothing is set?)
Also, these settings could definitely use an example in the description, since users might not know what these mappings should look like.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I should have closed this PR earlier. I'm dropping it to work on smaller PRs (I already merged one of them). Regarding your suggestion: absolutely. I'll tackle that on my next PRs.

DylanGuedes added a commit that referenced this pull request Feb 5, 2025
**What this PR does / why we need it**:
Introduces the idea of policies to Loki, which are recognizable based on the given stream selectors.
This is an improved version of #15561 and built on top of #15875.
A policy mapping can be configured the following way:
```yaml
12345:
  policy_stream_mapping:
    policy6:
    - selector: `{env="prod"}`
      priority: 2
    - selector: `{env=~"prod|staging"}`
      priority: 1
    - selector: `{team="finance"}`
      priority: 4
    policy7:
    - selector: `{env=~"prod|dev"}`
      priority: 3
```
With that configuration, pushes to tenant `12345` with the labels `{env="prod", team="finance"}` would be assigned to policy6 because the third mapping for policy6 matches these labels and has higher priority than any other matching.
salvacorts pushed a commit that referenced this pull request Feb 12, 2025
**What this PR does / why we need it**:
Introduces the idea of policies to Loki, which are recognizable based on the given stream selectors.
This is an improved version of #15561 and built on top of #15875.
A policy mapping can be configured the following way:
```yaml
12345:
  policy_stream_mapping:
    policy6:
    - selector: `{env="prod"}`
      priority: 2
    - selector: `{env=~"prod|staging"}`
      priority: 1
    - selector: `{team="finance"}`
      priority: 4
    policy7:
    - selector: `{env=~"prod|dev"}`
      priority: 3
```
With that configuration, pushes to tenant `12345` with the labels `{env="prod", team="finance"}` would be assigned to policy6 because the third mapping for policy6 matches these labels and has higher priority than any other matching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL 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.

2 participants