proposal: Change architecture for loki pipelines#4940
Merged
Conversation
thampiotr
reviewed
Nov 28, 2025
thampiotr
reviewed
Nov 28, 2025
thampiotr
reviewed
Nov 28, 2025
thampiotr
reviewed
Nov 28, 2025
thampiotr
reviewed
Nov 28, 2025
27 tasks
3086ef0 to
951a719
Compare
951a719 to
fc4808e
Compare
fc4808e to
9d5e87f
Compare
kgeckhart
reviewed
Mar 11, 2026
This was referenced Mar 17, 2026
kalleep
added a commit
that referenced
this pull request
Mar 19, 2026
### Pull Request Details Migrate `loki.enrich` to use shared functions and structures for loki components, this is done to make it consistent with other component and to prepare for #4940. Also before we did not use the lock when reading stored args, this could lead to data races if a entry is processed at the same time the component is updated. ### Issue(s) fixed by this Pull Request <!-- Fixes #issue_id --> ### Notes to the Reviewer Moved Consume and Drain functions to shared loki package instead of having it in source package, we use them in non source components too. ### PR Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] Documentation added - [x] Tests updated - [ ] Config converters updated
This was referenced Mar 19, 2026
kalleep
added a commit
that referenced
this pull request
Mar 24, 2026
### Pull Request Details We have added some shared functionallity for working with loki pipelines and should use them in our `database_observability`. This will make it easier in the future to start to migrate to [new architecture for loki pipelines](#4940) and avoid common pitfalls. I did not review all `collectors` but just did a sample and e.g. [explain_plan](https://github.com/grafana/alloy/blob/main/internal/component/database_observability/mysql/collector/explain_plans.go#L469) can cause a deadlock when component is stopping and in turn preventing alloy from stopping because nothing is consuming from handler. Changes: 1. Use [loki.Fanout](https://github.com/grafana/alloy/blob/main/internal/component/common/loki/fanout.go#L19) - This is doing internal locking of logs receivers so components do not have to care about it. It will also stop forwarding when context is canceled. 2. Use [loki.Consume](https://github.com/grafana/alloy/blob/0ac6d7ca7c744268668189c0f11460a84c9ef458/internal/component/common/loki/consume.go#L13) - Runs the consume loop from a `LogsReceiver` and will exit when context is canceled. 3. Use [loki.Drain](https://github.com/grafana/alloy/blob/0ac6d7ca7c744268668189c0f11460a84c9ef458/internal/component/common/loki/drain.go#L18) - When components is stopping we need to still forward / drain to make sure collectors can stop. Since #5613 we have a deterministic order for stopping components so it is safe to forward to downstream components during stops but we still have a timeout after we would drain into nothing. 4. Use [loki.NewEntry](https://github.com/grafana/alloy/blob/0ac6d7ca7c744268668189c0f11460a84c9ef458/internal/component/common/loki/entry.go#L10) - This makes sure we set `created` timestramp of entries so they can be properly tracked by `loki_write_entry_propagation_latency_seconds`. ### Issue(s) fixed by this Pull Request Part of: #5826 ### Notes to the Reviewer <!-- Add any relevant notes for the reviewers and testers of this PR. --> ### PR Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] Documentation added - [ ] Tests updated - [ ] Config converters updated
x1unix
approved these changes
Mar 25, 2026
f1bef4e to
ef2a3f9
Compare
ptodev
approved these changes
Mar 26, 2026
Contributor
ptodev
left a comment
There was a problem hiding this comment.
Makes sense. To me this is also the most obvious way to improve reliability. I'm just worried about issues with sharding caused by edge cases. I don't see anything wrong in the proposal but I just wonder if I'm missing something. Hopefully if we have thorough tests we will cover all our bases.
kgeckhart
approved these changes
Mar 30, 2026
gaantunes
pushed a commit
that referenced
this pull request
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pr is used to add a proposal to change how loki pipeline works to address some issues we see today.