Skip to content

Allow positively overriding hostname#88

Merged
paweljw merged 4 commits into
mainfrom
pawel/runtime-hostname
Dec 10, 2025
Merged

Allow positively overriding hostname#88
paweljw merged 4 commits into
mainfrom
pawel/runtime-hostname

Conversation

@paweljw

@paweljw paweljw commented Dec 10, 2025

Copy link
Copy Markdown
Member
  • combines "positive signal" requirement with ability to set it per-machine
  • covers bootstrap, service starts/stops etc, because it's implemented in supervisor start script

should be enough to:

mkdir -p /var/lib/better-stack
cat /etc/hostname > /var/lib/better-stack/hostname.txt

and (re)starting containers

@paweljw paweljw requested a review from curusarn December 10, 2025 09:46
@paweljw paweljw marked this pull request as ready for review December 10, 2025 09:46
@curusarn

Copy link
Copy Markdown
Contributor

combines "positive signal" requirement

I don't know what this means please. Could you dumb it down for me? 🙏

@paweljw

paweljw commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

@curusarn apologies for opaque language 🙏

I mean: we already have $HOSTNAME set in install scripts on all-ish platforms. Rather than overriding user's choice by e.g. always reading /etc/hostname, I wanted a strong positive signal the user wants the hostname overridden at runtime. In this case, explicitly creating a file means: "I know what I'm doing and I want this overridden".

@curusarn

Copy link
Copy Markdown
Contributor

This allows us to override ENV HOSTNAME by writing /var/lib/better-stack/hostname.txt.

When do we plan to write into /var/lib/better-stack/hostname.txt please?

Does the customer need to write the hostname?

@paweljw

paweljw commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

When do we plan to write into /var/lib/better-stack/hostname.txt please?

Does the customer need to write the hostname?

We don't, because for most use-cases setting HOSTNAME at install-time is sufficient. I'm imagining the file would be created e.g. in an instance setup script. That's why I wanted the action needed to be blazing-fast and one-time.

Hence my point about adding it to the docs. It'd be part of Advanced configuration.

@curusarn

curusarn commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

@curusarn apologies for opaque language 🙏

I mean: we already have $HOSTNAME set in install scripts on all-ish platforms. Rather than overriding user's choice by e.g. always reading /etc/hostname, I wanted a strong positive signal the user wants the hostname overridden at runtime. In this case, explicitly creating a file means: "I know what I'm doing and I want this overridden".

Why don't we read /etc/hostname anytime HOSTNAME env is unset?

  • We'd get /etc/hostname at runtime normally.
  • Overriding hostname would be possible via setting HOSTNAME before running install.sh.

I'm not excited to see a custom file introduced for something as simple as setting hostname. 🙏

@paweljw

paweljw commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

@curusarn

Why don't we read /etc/hostname anytime HOSTNAME env is unset?

Would it be ever? Or are you thinking that it should be overridden if e.g. explicitly set to an empty string? HOSTNAME="" ... install.sh?

Probably would need uts: host on both containers + Kubernetes equivalent + Swarm equivalent. Or mounting /etc/hostname on Beyla container.

The more mounts/more privileges slightly scared me off going that route :) But if you feel strongly that's the way to go, I'll do that 🙏

@paweljw

paweljw commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

@curusarn adjusted to use uts: host. On second thought, for Kubernetes and Swarm this shouldn't be an issue at all.

@curusarn

curusarn commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

@curusarn adjusted to use uts: host. On second thought, for Kubernetes and Swarm this shouldn't be an issue at all.

Thanks! 🙏
Generally, I didn't want extra steps to get correct hostname. Feels like something that should "just work". (even when baking collector into AMI)

ChatGPT claims Datadog get hostname from docker socket via docker info --format '{{.Name}}'.
If that works we wouldn't need UTS.

I'm fine with uts: host in docker compose. We set the env in Kubernetes and Swarm so we don't need it there. 👍

@paweljw

paweljw commented Dec 10, 2025

Copy link
Copy Markdown
Member Author

@curusarn

ChatGPT claims Datadog get hostname from docker socket via docker info --format '{{.Name}}'. If that works we wouldn't need UTS.

True, but we also don't ship docker binary in our containers. Could be done with raw API access, but that's sort of out there. :)

@curusarn curusarn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@curusarn

Copy link
Copy Markdown
Contributor

Thanks! "uts: host" seems fine & simple. We can always adjust later. 🙏

@paweljw paweljw merged commit 02ede45 into main Dec 10, 2025
4 checks passed
@paweljw paweljw deleted the pawel/runtime-hostname branch December 10, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants