Skip to main content

Loki

Log aggregation system. Indexes log metadata (labels) rather than full text, keeping storage cheap while still supporting rich log queries in Grafana.

What's configured​

Two containers work together:

ServiceRole
lokiStores and indexes logs. Port 3100 on the exist network, on 127.0.0.1:43100 (LOKI_BIND in hosting/loki/.env; keep it loopback, as Loki has no login), and, on the controller, at https://model-gateway.<domain> through Caddy and the model gateway, with the fleet secret: where every host's reporting plugin pushes (Controller and Workers)
loki-alloyTails every container's log and ships it to Loki

Grafana Alloy replaced Promtail, which Grafana declared feature-complete and end-of-lifed in March 2026. Its config (loki-alloy-config.alloy) is written in Alloy's own configuration language, not YAML.

Decree runs are not tailed here. Every host that reports ships its own, live, with a native alloy the reporting plugin starts in a tmux session (reporting-alloy): each run's events.jsonl (decree's own record, one JSON line per step) as {job="decree"} and each script's output as {job="decree_script"}, from existential's three decree projects:

LabelValues
hostthe host the run was on
projectautomation, automation-backup, host
machinethe machine that ran (events.jsonl lines)
typetransition, script, run_finished, … (events.jsonl lines)
scriptthe script that wrote the output (decree_script lines; blank when it is the state's own)

run_id is structured metadata, not a label, so one run is {job="decree"} | run_id="<id>". Grafana's Decree Overview and its alerts read these.

loki-alloy tails every container's json-file log under /var/lib/docker/containers as {job="docker"}. Those lines have no container name, only the container id in filename (docker inspect it): naming them would need the Docker socket, which is host root.

Storage​

Single-node filesystem storage under /loki in the volume loki_data, TSDB index on schema v13. Old samples beyond 168h (7 days) are rejected on ingest, and the compactor deletes anything older than 720h (30 days). The embedded query cache is capped at 100 MB.

loki_data is on this host's own disk, never the NAS: Loki's index needs file locking NFS does not give it reliably. What bounds it is the 30 days.

Docker's own copy of each container's output, the json-file log that loki-alloy reads, is capped at three 10 MB files per container (./existential.sh writes that into every service in docker-compose.yml), so a noisy container cannot fill the disk. Loki logs only warnings and errors (log_level in loki-config.yaml): its own log is one of the ones it ingests.

Querying​

Loki is not meant to be queried directly. Use Grafana with the pre-configured Loki datasource and LogQL:

{job="decree", type="run_finished"} | json | state != "done"
{job="decree", machine="gmail_sync", type="run_finished"} | json | duration_ms > 10000