Grafana Loki is a log aggregation system inspired by Prometheus. It indexes labels, not content — making it 10x cheaper than Elasticsearch for logs.
What Is Loki?
Loki stores logs efficiently by only indexing metadata (labels) while keeping log lines compressed in object storage. Query with LogQL.
Why Loki?
- 10x cheaper than Elasticsearch
- Native Grafana integration
- Prometheus-like label model
- S3/GCS/MinIO storage
- Multi-tenant
Quick Start
docker run -p 3100:3100 grafana/loki:latest
HTTP API
# Push logs
curl -X POST http://localhost:3100/loki/api/v1/push \
-H "Content-Type: application/json" \
-d '{"streams":[{"stream":{"app":"myapp","level":"error"},"values":[["1679500000000000000","Connection refused to database"]]}]}'
# Query logs
curl -G http://localhost:3100/loki/api/v1/query_range \
--data-urlencode "query={app=\"myapp\"}" \
--data-urlencode "limit=10"
# Query with filter
curl -G http://localhost:3100/loki/api/v1/query_range \
--data-urlencode "query={app=\"myapp\"} |= \"error\""
Use Cases
- Centralized logging — all app logs in one place
- Kubernetes logging — native k8s integration
- Cost reduction — replace expensive ELK stacks
- Alert on logs — Grafana alerting rules
- Compliance — long-term log retention on S3
Loki vs Alternatives
| Feature | Loki | Elasticsearch | Datadog |
|---|---|---|---|
| Index strategy | Labels only | Full-text | Full-text |
| Storage cost | Low | High | Very high |
| Query language | LogQL | KQL | Custom |
| Grafana native | Yes | Plugin | Plugin |
Need web data at scale? Check out my scraping tools on Apify or email spinov001@gmail.com for custom solutions.
Top comments (0)