# Loki's own metrics -> Prometheus (scrape + ingest-rate guard). # # The ServiceMonitor sits in the monitoring namespace (where the Prometheus # serviceMonitorSelector lives) and reaches the Service in `logging` through # namespaceSelector, mirroring monitoring/controllers/home/garage.yaml. apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: loki namespace: monitoring labels: release: kube-prometheus-stack app.kubernetes.io/part-of: logging spec: namespaceSelector: matchNames: - logging selector: matchLabels: app.kubernetes.io/name: loki endpoints: - port: http path: /metrics interval: 60s scrapeTimeout: 20s --- # Storage is bounded by retention + the 8Gi PVC, but local-path does not # enforce the PVC request, so the one number worth watching is the ingest rate: # sustained ingest far above the measured baseline (~100 MiB/day) is what would # eventually outrun chunk deletion. No Alertmanager is deployed in this stack, # so this surfaces under Prometheus -> /alerts (the same posture as every other # rule in monitoring/controllers/home/prune-alerts.yaml). apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: loki-ingest-guard namespace: monitoring labels: release: kube-prometheus-stack app.kubernetes.io/part-of: logging spec: groups: - name: logging-storage rules: - alert: LokiIngestRateAboveBudget # 200 kB/s raw ~= 17 GB/day ~= 2 GB/day compressed, which fills the # 8Gi PVC inside the 192h window. Measured baselines: 4 kB/s quiet, # ~37 kB/s during an osint crawl (2026-11-27, see docs/logging.md), # so this only fires on a real runaway (log loop, debug left on). expr: | sum(rate(loki_distributor_bytes_received_total[30m])) > 200 * 1024 for: 1h labels: severity: warning annotations: summary: Loki ingest is above the storage budget description: >- Loki is receiving {{ $value | humanize1024 }}B/s (>200 kB/s), which is ~17 GB/day raw — enough to fill the 8Gi PVC before the 192h retention can delete anything. Either a workload started logging in a loop, or retention / limits need revisiting before the disk does. - alert: LokiDown expr: up{job="loki"} == 0 for: 10m labels: severity: critical annotations: summary: Loki is not being scraped description: >- The log store is down: nothing is being written or queried, and the 192h retention clock is no longer being maintained by the compactor.