Skip to content

Conversation

imbstack
Copy link

Summary

On clusters with high numbers of namespaces, Vector's memory can grow rather large. Additionally the load that Vector puts on kube-apiserver can be rather heavy when rolling the Vector daemonset or otherwise have many Vector pods restarting. This change allows you to opt out of having namespace labels available for enrichment. I believe that if you try to use them with namespace listwatching disabled Vector will gracefully log an error rather than crash or something along those lines which feels like a good way to handle this scenario?

This is my first contribution to Vector, I think I've read through the guidelines and such but am happy to make any changes you think would be best, this is just my guess at a good way to solve this issue for us.

Vector configuration

There's quite significant amount of config on my test setup in our staging clusters. I can try to trim it down and get a test setup going if we'd be more comfortable with this change being tested that way first though.

How did you test this PR?

I backported these changes (technically just 6389f2f0c16a157579e2cfe4662d280e8688608a, the changes I made after that have not been deployed anywhere) to 0.37.1 and built/deployed images based on this into our staging environment. This cut the memory usage of Vector pods in half in a cluster with many tens of thousands of namespaces. I have not tested the version of this based on master. I'm happy to get a test setup going to try this out if we really want to, the clusters I have available to me now need to be updated too significantly for me to want to bother with it on them at the moment.

Change Type

  • Bug fix
  • New feature
  • 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

Implements: #22990

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:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • 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 cargo vdev build licenses to regenerate the license inventory and commit the changes (if any). More details here.

The namespaces cache will be an empty store in this case. Down
the line all of the code _should_ just work for instance emitting
an error log if you try to access namespace labels.
@imbstack imbstack requested review from a team as code owners August 15, 2025 23:54
@github-actions github-actions bot added domain: sources Anything related to the Vector's sources domain: external docs Anything related to Vector's external, public documentation labels Aug 15, 2025
@imbstack
Copy link
Author

imbstack commented Aug 16, 2025

Ah, this seems to have broken something. It runs but isn't emitting the logs I expect. I'll close this and re-open when I figure this out. Sorry for the noise!

This seems to work now!

@imbstack imbstack closed this Aug 16, 2025
@imbstack imbstack reopened this Aug 16, 2025
@rtrieu rtrieu self-assigned this Aug 18, 2025
Copy link
Contributor

@rtrieu rtrieu left a comment

Choose a reason for hiding this comment

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

Some suggestions to improve readability. Let me know if you have any questions about my feedback!

@imbstack
Copy link
Author

Great feedback, thank you!

@pront pront self-assigned this Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: external docs Anything related to Vector's external, public documentation domain: sources Anything related to the Vector's sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants