Loki
Log aggregation system optimized for Grafana.
Overview
Loki collects and indexes logs from all containers via Alloy.
| Property | Value |
|---|---|
| Image | grafana/loki:3.0.0 |
| Container | loki |
| Port | 3100 (internal) |
| Config | ~/ravenhelm/services/loki/ |
| Data | ~/ravenhelm/data/loki/ |
Quick Commands
# View logs
docker logs -f loki
# Restart
docker restart loki
# Check ready
curl http://localhost:3100/ready
# Query labels
curl http://localhost:3100/loki/api/v1/labels
# Query logs
curl -G http://localhost:3100/loki/api/v1/query_range \
--data-urlencode 'query={container="traefik"}' \
--data-urlencode 'limit=10'
Log Labels
| Label | Description |
|---|---|
container | Container name |
job | Job name (e.g., "containers") |
host | Source host |
level | Log level (if parsed) |
Common Queries (LogQL)
# All container logs
{job="containers"}
# Specific container
{container="norns-agent"}
# Filter by content
{container="traefik"} |= "error"
# JSON parsing
{container="norns-agent"} | json | level="error"
# Rate of errors
rate({container="traefik"} |= "error" [5m])
# Top 10 error messages
topk(10, sum by (message) (count_over_time({job="containers"} |= "error" | json [1h])))
Configuration
loki-config.yaml
auth_enabled: false
server:
http_listen_port: 3100
common:
path_prefix: /loki
storage:
filesystem:
chunks_directory: /loki/chunks
rules_directory: /loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory
schema_config:
configs:
- from: 2020-10-24
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
limits_config:
retention_period: 30d
Troubleshooting
Issue: No Logs Appearing
Symptoms: Grafana shows no logs from Loki
Diagnosis:
# Check Loki is receiving logs
curl http://localhost:3100/loki/api/v1/labels
# Check Alloy is forwarding
docker logs alloy | grep loki
Solutions:
- Verify Alloy is running and configured
- Check network connectivity to Loki
- Verify log labels match query