# Pod logs and metrics The swarm's log and metric stores stay where they are. A pod's output reaches them through the hive collector that runs on the host (`opentelemetry-collector`, [Telemetry](../swarm/telemetry.md)), so `swarm-logs query` and `swarm-metrics` show a pod's records next to the ones the same service produced as a host unit. ## Metrics A pod pushes OTLP to `http://hive-collector.hive:4318`, the address agents use. The node's CoreDNS answers the name with the hive bridge's address ([The cluster node](node.md)). The [renderer](manifests.md) sets `OTEL_EXPORTER_OTLP_ENDPOINT` to that address in every pod. For `swarm-ci-metrics`, whose poller reads `SWARM_CI_METRICS_OTLP_ENDPOINT`, it sets that variable too. A unit's own endpoint is a loopback forwarder or a gateway route that needs a token, and a pod has neither. A host without a hive collector keeps the unit's value. The collector stamps the hive's `hive` label on what it forwards, as it does for agents. The pods run on that hive's node. ## Logs With `services.hyperhive.deploy.k8s.enable` on a host that runs the hive collector, the collector gains a `file_log/pods` receiver on `/var/log/pods/*/*/*.log`, where the container runtime writes each container's output. One node means one reader, with no per-node agent. The receiver: - reads the CRI framing, and takes the namespace, pod, uid and container name from the file's path into resource attributes (`k8s.*`); - reads the level of hive-log's text format, a timestamp then the level (`WARN`, `INFO`), into the record's severity. A line in another shape keeps no severity; - keeps its read offsets in the collector's `file_storage`, so a restart resumes where it stopped. `service.name` is the container's name without `swarm-`: `controller`, `notify-router`, `ci-metrics`. That matches what the swarm's container services stamp on their journal records. The host units of `swarm-controller` and `swarm-ci-metrics` carry no `service.name` on their journal records, so a pod's output is the first to carry one for them. ## Access to the files The container runtime writes a log file as root with mode 0640, and the nixpkgs collector unit runs as a dynamic user. With the node on, the collector runs as the static user `opentelemetry-collector`, and `systemd-tmpfiles` puts an ACL on `/var/log/pods`: read and traverse for that user on the directory and on everything under it, with a default entry so the directories kubelet creates later inherit it. The rule also creates the directory, mode 0755 as kubelet creates it. The user reads nothing else the file mode doesn't already let every user read. With the node off, the unit and the collector's configuration are the ones it has without the module. ## Validation `module-eval-k8s` checks the configuration with the option on and off, the rendered endpoints, and the ACL's path. The VM test `k8s-node` runs a pod that writes a `WARN` and an `INFO` line, and checks that the collector's user reads the pod's log file, that the lines arrive with those severities under the container's name, and that a metric a pod pushes arrives.