56 lines
1.4 KiB
Django/Jinja
56 lines
1.4 KiB
Django/Jinja
---
|
|
# roles/monitoring_stack/templates/loki-config.yml.j2
|
|
# Loki configuration for centralized log aggregation
|
|
|
|
# === CONCEPT: Loki vs Traditional Logging ===
|
|
# Traditional: Index entire log content (expensive, slow)
|
|
# Loki: Index only metadata labels (cheap, fast)
|
|
# Think of Loki as "Prometheus for logs"
|
|
|
|
auth_enabled: false
|
|
|
|
server:
|
|
http_listen_port: {{ loki_port }}
|
|
grpc_listen_port: 9096
|
|
|
|
common:
|
|
path_prefix: /loki
|
|
storage:
|
|
filesystem:
|
|
chunks_directory: /loki/chunks
|
|
rules_directory: /loki/rules
|
|
replication_factor: 1
|
|
ring:
|
|
instance_addr: 127.0.0.1
|
|
kvstore:
|
|
store: inmemory
|
|
|
|
schema_config:
|
|
configs:
|
|
- from: 2024-01-01
|
|
store: tsdb
|
|
object_store: filesystem
|
|
schema: v13
|
|
index:
|
|
prefix: index_
|
|
period: 24h
|
|
|
|
# === RETENTION: Automatic Log Cleanup ===
|
|
# Keeps logs for {{ loki_retention }} (default: 7 days)
|
|
# Prevents disk from filling up with old logs
|
|
limits_config:
|
|
retention_period: {{ loki_retention }}
|
|
reject_old_samples: true
|
|
reject_old_samples_max_age: 168h
|
|
|
|
# === PRO-TIP: Query Optimization ===
|
|
# Limit concurrent queries to prevent overload
|
|
query_scheduler:
|
|
max_outstanding_requests_per_tenant: 100
|
|
|
|
# === LABEL EXTRACTION ===
|
|
# Automatically extract structured fields from logs
|
|
# Example: {"level":"error"} becomes label level="error"
|
|
ruler:
|
|
alertmanager_url: http://localhost:9093
|