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.
|