Loki is a cost-effective log aggregator with an index-free approach. This episode discusses its component architecture, how label-based storage works, a comparison with Elasticsearch, and log parsing strategies from structured formats to label extraction.

The second pillar of observability is logs — detailed records of exactly what happened. But collecting logs from thousands of services is no trivial task: volume can reach terabytes per day, and storage costs are often the biggest burden.
Grafana Loki came to answer that problem. Inspired by Prometheus' design, Loki is built as a log aggregation system that is horizontally scalable and cost-effective, with a storage approach completely different from Elasticsearch. This episode covers Loki's architecture, its comparison with Elasticsearch, and log formats and parsing strategies.
Loki does not index the content of every log line. Instead, it only indexes labels — key-value pairs attached to each log stream. Line content is stored as-is in compressed chunks.
The benefits of this approach are enormous:
docker exec loki /usr/bin/loki --versionThe docker exec loki /usr/bin/loki --version command shows the version of the binary inside the container — a small habit that's useful when verifying a deployment.
Like Mimir, Loki splits the data path into small components:
client -> distributor -> ingester -> object storage
^ |
query -> query-frontend -> querier <- index-gatewayThe distributor -> ingester -> object storage diagram shows the write path, while the query path is assisted by the index-gateway for label lookups.
loki: label-first, cheap, good for observability
elasticsearch: full-text, expensive, good for searchThe pattern above doesn't mean one is better — choose based on need. loki: label-first is the default choice in this series because of cost.
Structured logs are in JSON or logfmt form so machines can parse them easily:
{
"level": "info",
"ts": "2026-08-10T10:05:11Z",
"service": "orders",
"order_id": "ord-1042",
"msg": "order created"
}Unstructured logs are just free text. Loki accepts both, but structured logs are far easier to analyze with LogQL in episode 10.
An important principle in Loki: labels are limited, parsing happens at query time. Just use a few stable labels like job, service, and level; the rest is parsed from log content using LogQL parsers like json, logfmt, or pattern.
labels:
job: checkout
service: payment
level: errorThe labels concept above is similar to Prometheus labels — always think about cardinality before adding a new label.
Info
The most common mistake Loki users make is using too many labels. Remember: labels are only for log streams, while dynamic data like order_id must stay in the log line content.
In episode 9 you understood that Loki is an index-free log aggregator that only indexes labels, learned its architectural components from distributor to compactor, compared its approach with Elasticsearch, and understood the importance of structured logs and disciplined label strategy.
The key takeaways:
In the next episode 10 we'll discuss LogQL — Loki's query language for selecting log streams, filtering lines, parsing content, up to computing metrics from logs like rate and count_over_time. Your stored logs will soon be quick to explore.