A Grafana Loki configuration builder that produces a complete loki.yaml covering the sections a
real deployment needs: server, common/ring, schema_config, storage_config (filesystem
or S3), limits_config, compactor, and ruler. Loki is a horizontally-scalable log
aggregation system that indexes only labels — not full log text — so it pairs naturally with
Prometheus and Grafana.
How it works
Loki’s config is organised by component. server sets the HTTP and gRPC ports. common ties
together the ring (instance addressing and replication) and the default storage path. schema_config
declares how data is laid out over time — current Loki uses the tsdb index store with the v13
schema and a 24h index period; schema entries are append-only and keyed by a from date so old data
keeps its old layout. storage_config then points the chosen store at a location: a local directory
for filesystem, or a bucketnames/region/endpoint for aws/S3-compatible object storage.
limits_config caps per-tenant ingestion (ingestion_rate_mb, ingestion_burst_size_mb) and sets
retention_period. Retention only actually deletes data when the compactor runs with
retention_enabled: true, so the builder always pairs the two. The ruler evaluates alerting and
recording rules over logs.
Storage example
A production S3 schema entry plus storage block looks like this:
schema_config:
configs:
- from: 2024-01-01
store: tsdb
object_store: aws
schema: v13
index:
prefix: index_
period: 24h
Notes
Schema changes are forward-only — append a new entry with a future from date instead of editing the
existing one, or Loki will fail to read older chunks. Keep S3 credentials out of the file (use IAM
roles or env injection), and run the compactor as a singleton so retention is enforced exactly once.