Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nabokihms
Copy link
Contributor

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).

env:
- name: VECTOR_HOSTNAME
  valueFrom:
    fieldRef:
      fieldPath: spec.nodeName

Change Type

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

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

Tested manually in the kubernetes cluster.

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.

Checklist

  • Please read our Vector contributor resources.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

Closes #20481

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]>
@nabokihms nabokihms requested a review from a team as a code owner November 13, 2024 22:32
Copy link
Contributor

@pront pront left a 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)

src/lib.rs Outdated Show resolved Hide resolved
@nabokihms nabokihms requested review from a team as code owners November 15, 2024 07:06
@github-actions github-actions bot added the domain: external docs Anything related to Vector's external, public documentation label Nov 15, 2024
@nabokihms nabokihms requested a review from pront November 15, 2024 10:56
Copy link
Contributor

@urseberry urseberry left a 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.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use VECTOR_SELF_NODE_NAME for internal_metrics
3 participants