feat(loki.source.podlogs): add preserve_discovered_labels option#4606
Conversation
Add a new preserve_discovered_labels parameter to loki.source.podlogs component that allows discovered Kubernetes metadata labels to be preserved and forwarded to downstream components like loki.relabel. When enabled, this option preserves __meta_kubernetes_* labels that would normally be stripped after relabeling, enabling component chaining where pod metadata can be accessed by downstream relabeling components. Fixes grafana#2526
|
|
||
|
|
||
| When `preserve_discovered_labels` is disabled (the default), `loki.source.podlogs` doesn't export any fields. |
There was a problem hiding this comment.
| When `preserve_discovered_labels` is disabled (the default), `loki.source.podlogs` doesn't export any fields. | |
| When `preserve_discovered_labels` is disabled (the default), `loki.source.podlogs` doesn't export any fields. |
Remove empty lines.
Do we need to document what happens when preserve_discovered_labels is enabled? What is exported when it's enabled?
|
Thank you @clayton-cornell :) |
|
Still wondering about this one: Do we need to document what happens when |
|
The discovered Labels are send downstream components like Loki process (which is not the case by default) but are dropped by either loki.process or loki.write upon complétion of the pipeline |
|
Thank you!!! Much needed. Happy to help test on live clusters. |
|
@kalleep I think the changelog of my previous PR was not set in the correct place so I updated it here if that's alright? |
kalleep
left a comment
There was a problem hiding this comment.
Because loki.write drops any labels that starts with __ but the _tenant_id label, this should not impact downstream Loki but would definitely help loki.source.podlogs users/
This is not true but there is a pr up to fix this that I have should take another look at https://github.com/grafana/alloy/pull/4601/files.
Otherwise this looks good except there is still an unresolved comment from @clayton-cornell
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
|
Oh i think i might have mixed components up. I remember one of them used to drop the __meta, but maybe it was the loki.source.api. Sorry about the confusion |
Well it's documented that we do drop all internal labels https://grafana.com/docs/alloy/latest/reference/components/loki/loki.write/#technical-details but we don't do it 🙈 |
|
Oh that makes sense. But you might want to not drop the __tenant label though |
Nope we don't want to do that. As I said I need to take a look at that pr :) |
|
Thank you for your awesome help :) |
|
There's a couple doc suggestions that look like they were resolved without applying the change - capitalizing Pod. This is a doc standard across the Grafana docs when referencing a Kubernetes Pod. If you take a look at the Kubernetes docs, you can see it's capitalized there too, and we should follow the upstream naming. |
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
|
Sorry @clayton-cornell , I don't know what happened. I think I merged them all |
All good :-) multiple eyes on a PR and we get it all sorted |
|
Just some lint issue and merge conflict with changelog but then we should be good to go 👍 |
|
@kalleep it should be fixed now :) |
PR Description
Add a new preserve_discovered_labels parameter to loki.source.podlogs component that allows discovered Kubernetes metadata labels to be preserved and forwarded to downstream components like loki.relabel.
When enabled, this option preserves _meta_kubernetes* labels that would normally be stripped after relabeling, enabling component chaining where pod metadata can be accessed by downstream relabeling components.
Which issue(s) this PR fixes
Fixes #2526
Notes to the Reviewer
Because loki.write drops any labels that starts with
__but the__tenant_id_label, this should not impact downstream Loki but would definitely helploki.source.podlogsusers/PR Checklist