Skip to main content

Loki

Log aggregation system optimized for Grafana.


Overview

Loki collects and indexes logs from all containers via Alloy.

PropertyValue
Imagegrafana/loki:3.0.0
Containerloki
Port3100 (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

LabelDescription
containerContainer name
jobJob name (e.g., "containers")
hostSource host
levelLog 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:

  1. Verify Alloy is running and configured
  2. Check network connectivity to Loki
  3. Verify log labels match query