-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(internal): Add VECTOR_HOSTNAME env variable #21789
feat(internal): Add VECTOR_HOSTNAME env variable #21789
Conversation
By default, Vector uses the hostname returned by the gethostname. However, in cases when Vector is running in containers, it is meaningless because hostname is always the name of the container, e.g., the name of a pod in Kubernetes cluster. This commit adds the way to override a hostname by using the env variable. In Kubernetes it can be used like this to see the name of a node where the Vector process is running (which is more meaningful). ``` env: - name: VECTOR_HOSTNAME valueFrom: fieldRef: fieldPath: spec.nodeName ``` Signed-off-by: maksim.nabokikh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nabokihms, thank you for this enhancement. Please also document this new env var in website/cue/reference/cli.cue
.
(Tangential to this PR: #21794)
353fa41
to
270821a
Compare
Signed-off-by: maksim.nabokikh <[email protected]>
270821a
to
98b1f3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a suggestion about a grammar nit.
changelog.d/21789_add_vector_hostname_env_variable.enhancement.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Ursula Chen <[email protected]>
- Fix cue formatting - Use the variable value if set but empty Signed-off-by: maksim.nabokikh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I'll let @pront approve too since he was looking at it before.
I think we could (potentially) add this as a global option in the config file too (hostname: foo
) but only if the hostname isn't fetched before global configuration is loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good call on not treating empty strings values as special.
Would be a nice follow-up to this. |
Summary
By default, Vector uses the hostname returned by the gethostname. However, in cases when Vector is running in containers, it is meaningless because hostname is always the name of the container, e.g., the name of a pod in Kubernetes cluster.
This commit adds the way to override a hostname by using the env variable. In Kubernetes it can be used like this to see the name of a node where the Vector process is running (which is more meaningful).
Change Type
Is this a breaking change?
How did you test this PR?
Tested manually in the kubernetes cluster.
Does this PR include user facing changes?
Checklist
Cargo.lock
), pleaserun
dd-rust-license-tool write
to regenerate the license inventory and commit the changes (if any). More details here.References
Closes #20481