Skip to content

fix(sources): fallback to file path metadata when pod annotation fails in kubernetes_logs#25834

Open
vparfonov wants to merge 1 commit into
vectordotdev:masterfrom
vparfonov:log-9584-upstream
Open

fix(sources): fallback to file path metadata when pod annotation fails in kubernetes_logs#25834
vparfonov wants to merge 1 commit into
vectordotdev:masterfrom
vparfonov:log-9584-upstream

Conversation

@vparfonov

Copy link
Copy Markdown
Contributor

Summary

When the kubernetes_logs source fails to annotate an event with pod metadata (e.g. pod already deleted before Vector could look it up), the event is sent downstream with no kubernetes metadata at all.

This causes issues in downstream transforms or sinks that expect fields like namespace_name to be present.

The file path (/var/log/pods/<ns>_<pod>_<uid>/<container>/<n>.log) always contains the basic metadata. This change makes the annotator fall back to populating namespace_name, pod_name, pod_uid, and container_name from the parsed file path when the pod is not found in the API store, instead of returning None and skipping all enrichment.

Vector configuration

Standard kubernetes_logs source — no special configuration needed.

How did you test this PR?

  • add unit test test_annotate_from_file_path

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

…s in kubernetes_logs

When the kubernetes_logs source fails to annotate an event with pod
metadata (e.g. pod already deleted before Vector could look it up),
the event is sent downstream with no kubernetes metadata at all.

This causes issues in downstream transforms that expect fields like
namespace_name to be present.

The file path (/var/log/pods/<ns>_<pod>_<uid>/<container>/<n>.log)
always contains the basic metadata. This change makes the annotator
fall back to populating pod_name, pod_namespace, pod_uid, and
container_name from the parsed file path when the pod is not found
in the API store, instead of returning None and skipping all
enrichment.

Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
@vparfonov
vparfonov requested a review from a team as a code owner July 14, 2026 15:17
@github-actions github-actions Bot added the domain: sources Anything related to the Vector's sources label Jul 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f28c798f59

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/sources/kubernetes_logs/pod_metadata_annotator.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: sources Anything related to the Vector's sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant