fix: security and monitoring improvements (issues 1-3) #1

Merged
greg merged 2 commits from klaatu/nixos:fix/security-and-monitoring into main 2026-03-25 12:09:28 +00:00
Collaborator

Summary

Three security and monitoring fixes identified during infrastructure audit.


Issue 1 — Grafana secret key hardcoded as 123456789

Replaced with an agenix-managed secret using Grafana's $__file{} interpolation. The .age file needs to be created before deploying:

pwgen -s 64 1  # generate the secret
agenix -e secrets/grafana-secret-key.age

All existing Grafana sessions will be invalidated on next deploy (users will need to log in again — expected behavior).


Issue 2 — Prometheus scraping retired vm-gitlab host

Removed vm-gitlab.shire-zebra.ts.net from the node, systemd, and ping scrape jobs. That VM is gone and was generating constant scrape errors. linode was already present in all jobs.


Issue 3 — Prometheus had no alerting rules

Added manifests/monitoring/alerts.yaml with a new prometheus-alerts ConfigMap containing rules for:

  • Host health: HostDown, HighCPULoad, LowDiskSpace, CriticalDiskSpace, HighMemoryUsage
  • Backup health: ResticBackupStaleness (alerts if a backup hasn't succeeded in >26h)
  • Kubernetes: PodCrashLooping, PodNotReady

Wired rule_files into prometheus.yml and updated the Prometheus deployment to mount the alerts ConfigMap as a separate volume subPath (previously the whole ConfigMap was mounted as a directory, which would have shadowed individual files — fixed that too).


Opened by Klaatu 🌌

## Summary Three security and monitoring fixes identified during infrastructure audit. --- ### Issue 1 — Grafana secret key hardcoded as `123456789` Replaced with an agenix-managed secret using Grafana's `$__file{}` interpolation. The `.age` file needs to be created before deploying: ```bash pwgen -s 64 1 # generate the secret agenix -e secrets/grafana-secret-key.age ``` All existing Grafana sessions will be invalidated on next deploy (users will need to log in again — expected behavior). --- ### Issue 2 — Prometheus scraping retired `vm-gitlab` host Removed `vm-gitlab.shire-zebra.ts.net` from the `node`, `systemd`, and `ping` scrape jobs. That VM is gone and was generating constant scrape errors. `linode` was already present in all jobs. --- ### Issue 3 — Prometheus had no alerting rules Added `manifests/monitoring/alerts.yaml` with a new `prometheus-alerts` ConfigMap containing rules for: - **Host health:** HostDown, HighCPULoad, LowDiskSpace, CriticalDiskSpace, HighMemoryUsage - **Backup health:** ResticBackupStaleness (alerts if a backup hasn't succeeded in >26h) - **Kubernetes:** PodCrashLooping, PodNotReady Wired `rule_files` into `prometheus.yml` and updated the Prometheus deployment to mount the alerts ConfigMap as a separate volume subPath (previously the whole ConfigMap was mounted as a directory, which would have shadowed individual files — fixed that too). --- > Opened by Klaatu 🌌
klaatu added 1 commit 2026-03-25 11:02:38 +00:00
Issue 1 - Grafana secret key:
- Replace hardcoded '123456789' secret_key in hosea Grafana config
  with an agenix-managed secret ($__file interpolation)
- Add age.secrets.grafana-secret-key declaration to hosea config
- Register grafana-secret-key.age in secrets/secrets.nix (publicKeys=everyone)
- NOTE: The .age file still needs to be created by running:
    agenix -e secrets/grafana-secret-key.age
  and entering a strong random secret (e.g. from 'pwgen -s 64 1')

Issue 2 - Prometheus stale targets:
- Remove retired vm-gitlab host from all three scrape jobs
  (node, systemd, ping) in manifests/monitoring/config.yaml
- linode was already present in all scrape jobs

Issue 3 - Prometheus alerting gaps:
- Wire up rule_files in prometheus.yml pointing at alerts.yml
- Add manifests/monitoring/alerts.yaml with alerting rules:
    * HostDown (node unreachable > 2m) - critical
    * HighCPULoad (>90% for 10m) - warning
    * LowDiskSpace (<10% free) - warning
    * CriticalDiskSpace (<5% free) - critical
    * HighMemoryUsage (>90% for 10m) - warning
    * ResticBackupStaleness (no success > 26h) - warning
    * PodCrashLooping - warning
    * PodNotReady (>10m) - warning
- Mount alerts ConfigMap as separate volume subPath in deployment
  so prometheus.yml and alerts.yml are both accessible at
  /etc/prometheus/ without conflicts
greg added 1 commit 2026-03-25 11:35:36 +00:00
fix: add new agenix file
buildbot/nix-eval Build done. (1 warning)
buildbot/nix-build Build done.
69ebf78d6c
greg merged commit 0050f866bf into main 2026-03-25 12:09:28 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: greg/nixos#1