No log store existed: pod logs were kubelet files on the node and died with the pod (~8h deepest history for a busy workload). Adds: - Loki 3.7.1 single-binary (1 Deployment + 8Gi local-path PVC on siriussec), retention_period 192h with the compactor deleting on filesystem, ingest rate limits, so the store is time- and rate-bounded. - Alloy 1.13.0 DaemonSet (all nodes, no RBAC, no API access) shipping /var/log/pods, /var/log/journal and the Pi's docker json logs. File sources read from byte 0 and stamp the timestamp from the line, so the history the nodes already held (18d cilium on linode, 31d registry on rpi) landed on day one instead of starting the 7-day clock at deploy time. - Grafana datasource (uid loki) via the existing sidecar, ServiceMonitor, ingest-rate guard rule. - docs/logging.md with the measured bytes/day, the 8-day projection and the runbook. Measured: ~360-502 MB/day raw -> ~90 MB/day compressed, 192h -> <=0.8GiB, on a node with 103GiB free (house floor 32GiB). Verified 7-day-old lines return for kube-system cilium-agent and for the siriussec/linode journals, and survive a Loki pod restart (PVC).
70 lines
2.5 KiB
YAML
70 lines
2.5 KiB
YAML
# 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
|
|
# ~1 GiB/day of *compressed* chunk data would blow the 8Gi bound
|
|
# before the compactor can keep up; the baseline is ~1% of this.
|
|
expr: |
|
|
sum(rate(loki_distributor_bytes_received_total[30m])) > 12 * 1024 * 1024
|
|
for: 1h
|
|
labels:
|
|
severity: warning
|
|
annotations:
|
|
summary: Loki ingest is above the storage budget
|
|
description: >-
|
|
Loki is receiving {{ $value | humanize1024 }}B/s (>12 MiB/s), which
|
|
is ~1 GiB/day of chunk data — more than the 8Gi PVC can hold for
|
|
192h. 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.
|