Overview
Loki aggregates and stores logs from all pods in the cluster, providing a scalable alternative to traditional log databases. It uses Garage (S3-compatible storage) as the backend for long-term log storage.Configuration
Nixidy Module (nixidy/env/local/loki.nix)
Architecture
Deployment Mode
SingleBinary mode runs all Loki components in one pod:- Distributor (receives logs)
- Ingester (writes chunks)
- Querier (reads logs)
- Compactor (optimizes storage)
Storage Backend
Loki uses Garage S3 for persistent storage:- Endpoint:
http://garage.storage:3900 - Bucket:
loki-chunks - Region:
garage - Path style: Forced (required for Garage)
garage-s3-credentials:
Schema Configuration
Loki uses TSDB schema (v13) for efficient log storage:Schema Features
- TSDB: Time-series database index format
- S3 object store: Chunks stored in Garage
- 24h index period: Daily index rotation
- v13 schema: Latest schema version
Service
Ports
| Port | Protocol | Purpose |
|---|---|---|
| 3100 | HTTP | Query API and metrics |
| 9095 | gRPC | Internal component communication |
Endpoint
- Internal URL:
http://loki.observability:3100 - Namespace:
observability
Persistence
Local Storage (WAL)
- Write-Ahead Log (WAL)
- Temporary chunk buffer before S3 upload
- Index cache
Object Storage (Chunks)
Log chunks are written to Garage S3:- Logs arrive at Loki
- Written to local WAL
- Batched into chunks
- Uploaded to
loki-chunksbucket in Garage - WAL flushed
Log Collection
Logs are collected via Promtail (or another Loki client):- Container logs from
/var/log/pods - Systemd journal
- Custom log files
Query Language (LogQL)
Loki uses LogQL for log queries:Label Filtering
Text Search
Parsed Fields
Aggregations
Integration
Grafana Data Source
Loki is configured as a Grafana data source:Tempo Correlation
Grafana links traces to logs:Garage S3
Loki depends on Garage for chunk storage:- Setup: Run
garage-setup.shto create bucket and credentials - Bucket:
loki-chunkscreated in Garage - Secret:
garage-s3-credentialsinjected into Loki pod
Performance
Replication Factor
Caching
Caches are disabled in local config:Storage Credentials
Loki accesses Garage via S3 credentials:AWS_ACCESS_KEY_ID: Garage access key (GK…)AWS_SECRET_ACCESS_KEY: Garage secret key
garage-setup.sh script.