swarm-otel: say what is measured about _HOSTNAME, not a mechanism that is wrong
The previous commit's comments explained `_HOSTNAME` being `nixos` with "no container sets `networking.hostName`", read off a `git grep` of this tree. That grep answers a question about our source; the default is nixpkgs': `nixos/modules/virtualisation/nixos-containers.nix` sets `networking.hostName = mkDefault name` for every `containers.<name>` guest, which is how every swarm service container here is declared. So the stated cause is wrong, and why the default does not reach these guests is still open. What is measured is narrower: an agent container reports `nixos`, and `_MACHINE_ID` is per-machine by construction. The comments now claim only that, and say the rest is unresolved. The code is unchanged — `_MACHINE_ID` in `_stream_fields` is correct regardless of which explanation turns out to be true. Refs #4304
This commit is contained in:
parent
bb38e1967c
commit
57aedc82ae
1 changed files with 13 additions and 9 deletions
|
|
@ -1107,10 +1107,12 @@ in
|
|||
# "everything except user sessions" is not expressible.
|
||||
#
|
||||
# Attribution is journald's either way — these fields are
|
||||
# written by it rather than by the logging process. ⚠️ But
|
||||
# `_MACHINE_ID` is the only one that separates containers:
|
||||
# none sets `networking.hostName`, so `_HOSTNAME` is the
|
||||
# NixOS default `nixos` everywhere but the host itself.
|
||||
# written by it rather than by the logging process. ⚠️ Use
|
||||
# `_MACHINE_ID` to tell machines apart, not `_HOSTNAME`: an
|
||||
# agent container reports the NixOS default `nixos`. Whether
|
||||
# every container does, and why the `networking.hostName`
|
||||
# nixos-containers sets does not reach them, is unresolved —
|
||||
# so rely on the field that is per-machine by construction.
|
||||
// lib.optionalAttrs collectLogs {
|
||||
journald = {
|
||||
directory = hostJournalDir;
|
||||
|
|
@ -1158,11 +1160,13 @@ in
|
|||
# literal `missing _msg field` as its message and text search
|
||||
# finds nothing, while ingest keeps answering 200.
|
||||
# `_stream_fields` is one stream per unit per machine.
|
||||
# `_MACHINE_ID` is what makes that true: `_HOSTNAME` reads
|
||||
# `nixos` in every container, so naming it alone merges every
|
||||
# container's stream for a unit name into one — which is how
|
||||
# two collectors sharing `opentelemetry-collector.service`
|
||||
# became one series.
|
||||
# `_MACHINE_ID` is what makes that true — it is per-machine by
|
||||
# construction, where `_HOSTNAME` is only as distinct as the
|
||||
# hostnames happen to be, and an agent container's is the
|
||||
# NixOS default `nixos`. Keying on the hostname alone merges
|
||||
# the streams of any two machines sharing one, which is what
|
||||
# the host and containerised `opentelemetry-collector.service`
|
||||
# would do.
|
||||
"otlphttp/victorialogs" = {
|
||||
logs_endpoint =
|
||||
logsPushUrl + "?_msg_field=MESSAGE&_stream_fields=_HOSTNAME,_MACHINE_ID,_SYSTEMD_UNIT";
|
||||
|
|
|
|||
Loading…
Reference in a new issue