feat(logging): ship all app logs to Loki and add Grafana Alloy syslog receiver #5

Open
tdpeuter wants to merge 4 commits from feat/loki-logging into dev
Owner

Summary

flowchart LR
    subgraph Hosts["Container Hosts (9)"]
        Apps["All App Containers\n(loki docker log-driver)"]
    end
    subgraph NAS["TrueNAS"]
        Syslog["Syslog (RFC5424 TCP)"]
    end
    subgraph Binnenpost["Binnenpost (192.168.0.89)"]
        Alloy["Grafana Alloy\nloki.source.syslog :1514"]
        Loki["Loki :3100"]
        Grafana["Grafana"]
    end

    Apps -->|"HTTP push"| Loki
    Syslog -->|"TCP :1514"| Alloy
    Alloy -->|"loki.relabel → loki.write"| Loki
    Loki --> Grafana
 modules/apps/
+├── pgadmin/default.nix          # extracted from hosts/Development
 ├── logging/default.nix          # add opt-in Grafana Alloy syslog receiver (v1.22.0)
 ├── gitea/default.nix            # Loki driver + FORGEJO__log__MODE=console
 ├── traefik/default.nix          # Loki driver + --accesslog=true
 └── */default.nix                # Loki driver + docker-loki-plugin-install ordering
 hosts/
 ├── Binnenpost/default.nix       # enable alloy + logging.client (127.0.0.1:3100)
 ├── Development/default.nix      # enable pgadmin module
 └── {Gitea,Niko,Production,ProductionArr,ProductionGPU,Testing,Vaultwarden}/default.nix
                                  # enable logging.client -> Binnenpost:3100

Note: 5c653c0 is a fixup! commit for 3792441 (replacing EOL Promtail with Grafana Alloy) ready for git rebase --autosquash before/at merge.

Evidence

  • Before: Only solidtime configured the Loki Docker log driver, only Development enabled homelab.apps.logging.client, pgadmin was inline in hosts/Development/default.nix, Forgejo logged to file, and no remote syslog receiver existed for TrueNAS.
  • After:
    • All 12 host configurations (Niko, Ingress, Gitea, Vaultwarden, Binnenpost, Production, ProductionGPU, ProductionArr, ACE, Template, Development, Testing) evaluate cleanly via nix eval .#nixosConfigurations.<host>.config.system.build.toplevel.drvPath (exit 0).
    • Extended changedetection module evaluates cleanly with log-driver = "loki".
    • Binnenpost's docker-alloy.service unit builds cleanly and alloy validate on the generated config.alloy exits 0.
    • loki, grafana, and alloy containers remain on local journald logging to avoid self-logging loops.

Merge Danger

Door: Two-way

All changes are declarative NixOS module/host configurations and roll back via previous NixOS generations. Containers retain local rotated log files (keep-file=true) and use mode=non-blocking.

Blast Radius: Fleet-wide

Deploying will install the grafana/loki-docker-driver plugin and recreate Docker containers on all 9 container hosts (Binnenpost, Development, Gitea, Vaultwarden, Production, ProductionArr, ProductionGPU, Testing, Niko), switch Forgejo to console logging, enable Traefik access logs, and expose TCP port 1514 on Binnenpost for TrueNAS syslog (192.168.0.89:1514, TCP / RFC5424).

## Summary ```mermaid flowchart LR subgraph Hosts["Container Hosts (9)"] Apps["All App Containers\n(loki docker log-driver)"] end subgraph NAS["TrueNAS"] Syslog["Syslog (RFC5424 TCP)"] end subgraph Binnenpost["Binnenpost (192.168.0.89)"] Alloy["Grafana Alloy\nloki.source.syslog :1514"] Loki["Loki :3100"] Grafana["Grafana"] end Apps -->|"HTTP push"| Loki Syslog -->|"TCP :1514"| Alloy Alloy -->|"loki.relabel → loki.write"| Loki Loki --> Grafana ``` ```diff modules/apps/ +├── pgadmin/default.nix # extracted from hosts/Development ├── logging/default.nix # add opt-in Grafana Alloy syslog receiver (v1.22.0) ├── gitea/default.nix # Loki driver + FORGEJO__log__MODE=console ├── traefik/default.nix # Loki driver + --accesslog=true └── */default.nix # Loki driver + docker-loki-plugin-install ordering hosts/ ├── Binnenpost/default.nix # enable alloy + logging.client (127.0.0.1:3100) ├── Development/default.nix # enable pgadmin module └── {Gitea,Niko,Production,ProductionArr,ProductionGPU,Testing,Vaultwarden}/default.nix # enable logging.client -> Binnenpost:3100 ``` Note: `5c653c0` is a `fixup!` commit for `3792441` (replacing EOL Promtail with Grafana Alloy) ready for `git rebase --autosquash` before/at merge. ## Evidence - **Before:** Only `solidtime` configured the Loki Docker log driver, only `Development` enabled `homelab.apps.logging.client`, `pgadmin` was inline in `hosts/Development/default.nix`, Forgejo logged to `file`, and no remote syslog receiver existed for TrueNAS. - **After:** - All 12 host configurations (`Niko`, `Ingress`, `Gitea`, `Vaultwarden`, `Binnenpost`, `Production`, `ProductionGPU`, `ProductionArr`, `ACE`, `Template`, `Development`, `Testing`) evaluate cleanly via `nix eval .#nixosConfigurations.<host>.config.system.build.toplevel.drvPath` (exit 0). - Extended `changedetection` module evaluates cleanly with `log-driver = "loki"`. - `Binnenpost`'s `docker-alloy.service` unit builds cleanly and `alloy validate` on the generated `config.alloy` exits `0`. - `loki`, `grafana`, and `alloy` containers remain on local `journald` logging to avoid self-logging loops. ## Merge Danger **Door:** Two-way All changes are declarative NixOS module/host configurations and roll back via previous NixOS generations. Containers retain local rotated log files (`keep-file=true`) and use `mode=non-blocking`. **Blast Radius:** Fleet-wide Deploying will install the `grafana/loki-docker-driver` plugin and recreate Docker containers on all 9 container hosts (`Binnenpost`, `Development`, `Gitea`, `Vaultwarden`, `Production`, `ProductionArr`, `ProductionGPU`, `Testing`, `Niko`), switch Forgejo to console logging, enable Traefik access logs, and expose TCP port `1514` on `Binnenpost` for TrueNAS syslog (`192.168.0.89:1514`, TCP / RFC5424).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin "feat/loki-logging:feat/loki-logging"
git switch "feat/loki-logging"

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch "dev"
git merge --no-ff "feat/loki-logging"
git switch "feat/loki-logging"
git rebase "dev"
git switch "dev"
git merge --ff-only "feat/loki-logging"
git switch "feat/loki-logging"
git rebase "dev"
git switch "dev"
git merge --no-ff "feat/loki-logging"
git switch "dev"
git merge --squash "feat/loki-logging"
git switch "dev"
git merge --ff-only "feat/loki-logging"
git switch "dev"
git merge "feat/loki-logging"
git push origin "dev"
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Bos55/nix-config!5
No description provided.