Loki vs Elasticsearch for Logs: A Cost and Latency Comparison

Philip Rehberger Nov 14, 2026 7 min read

Compare the two dominant log stacks on storage cost, query speed, and operational burden.

Logs are the most expensive observability signal to keep. They are also the most useful when something has gone wrong. Choosing where to store them is one of the highest-leverage observability decisions, and the two dominant options — Elasticsearch and Loki — have meaningfully different cost and operational profiles.

This comparison is not about which is "better." It is about which one fits the questions you ask and the bill you can absorb.

How They Index

The core difference is in what gets indexed.

Elasticsearch indexes every field of every log line. A log with 30 fields and a million entries produces an index that knows about all 30 million field values. Queries can filter and aggregate on any field at full speed. The cost is storage — typically 1.5-2x the raw log size after compression — and the cost of building and maintaining the index, which is CPU-intensive.

Loki indexes only labels — a small set of metadata applied at ingest time (service, level, environment). The log body itself is stored compressed in object storage, unindexed. Queries filter by label first, then scan the unstructured body. The cost is query latency for body-text searches; the benefit is that storage is roughly 1.1x the raw log size and the index is small.

The difference shows up in two places: query latency on text searches, and the cost curve as data grows.

Query Latency

A typical "find all logs containing this trace ID" query:

  • Elasticsearch: indexed, sub-second across multi-TB volumes. The trace ID is a field; the index returns matching documents directly.
  • Loki: scans the bodies of log streams matching the labels in the query. Speed depends on the label selectivity. A query like {service="checkout", level="error"} |= "trace_id=abc123" is fast if the label filter narrows to a few thousand log lines; slow if it narrows to a few million.

The Loki pattern works well when queries always include strong label filters. It works poorly when queries are exploratory across the whole dataset.

Storage Cost

For a workload generating 1 TB of logs per day with 30-day retention:

  • Elasticsearch on standard storage: roughly 60 TB of disk (raw + replicas + index overhead). At cloud SSD prices, $5K-$10K/month just for storage. CPU and memory for index maintenance add similar amounts.
  • Loki with S3: roughly 35 TB of object storage. At $0.023/GB/month, around $800/month. Compute is much lighter.

The 10x cost difference at this scale is real. It is also the most common reason teams migrate from Elasticsearch to Loki.

Operational Complexity

Elasticsearch is a distributed database. You operate it as one. Shard sizing, replica counts, master nodes, hot/warm/cold tiers, JVM tuning, index lifecycle management — all of this is real work. The reward is a fast, flexible system; the price is that someone is on call for it.

Loki is simpler operationally. Components are stateless or rely on object storage for state. There is no JVM, no shard rebalancing, no "this index is huge and I cannot move it." The Loki stack (distributor, ingester, querier, compactor) scales horizontally on Kubernetes with predictable behavior.

For a team without dedicated Elasticsearch ops experience, Loki's operational profile is easier to live with. For a team that has Elasticsearch experience and prefers the query flexibility, the gap is smaller.

Query Language

Elasticsearch uses two query languages depending on the interface: the JSON Query DSL for the REST API and Kibana's KQL for the UI. The DSL is powerful and verbose. KQL is simpler but covers a subset. Both have a learning curve.

Loki uses LogQL — a PromQL-derived language. Selector first, then pipeline. The pipeline supports filter, parse, label-extract, and aggregation operations. A typical query:

{service="checkout"} 
  |= "error" 
  | json 
  | duration > 100ms

LogQL is more constrained than Elasticsearch's query language but well-shaped for the operational queries SREs actually run. Teams already using PromQL pick it up in a day.

What About Hybrid

A pattern that has emerged: keep hot logs (last 7 days) in Elasticsearch for fast exploratory queries, ship cold logs to object storage with Loki or a similar engine. The Elasticsearch deployment stays small and fast; the long-term retention is cheap.

This works but adds operational complexity. You now run two systems. The query interface is different for each. Cross-system queries do not exist.

A simpler version: use Loki for everything, but tag the high-value services with more granular labels so common queries hit narrow label sets. Most of the value of the hybrid setup can be replicated by good label hygiene.

Where Elasticsearch Still Wins

There are still domains where Elasticsearch's full-text indexing is the right answer:

  • Application logs as a search product. Customer-facing log search, audit log search with arbitrary field filtering, security event correlation across many dimensions. These need indexed access.
  • Free-form exploration across the whole dataset. When you do not know which service or label to start from, Elasticsearch's index lets you search the haystack itself.
  • Mixed log + business event use cases. Teams using the same storage for application logs and product events — analytics, search relevance tuning — benefit from full indexing.

The common thread: when the query workload is unpredictable and full-text-driven, indexing pays off. When the query workload is operational and label-driven, it does not.

Where Loki Still Wins

Loki dominates in the inverse scenarios:

  • Kubernetes operational logs. Labels naturally come from pod metadata. Queries are scoped to specific services. The pattern fits the tool.
  • High-volume, low-value-per-line logs. Application access logs, debug logs, request traces. Storing them is cheap; querying them happens only during specific incidents.
  • Cost-sensitive environments. Startups, internal tooling, dev environments. The 10x cost gap is decisive.

Loki also wins when the team prefers the simpler operational model and is comfortable with the query latency tradeoff.

Migration Notes

A few patterns from teams that have migrated:

  • Run both for a quarter. Ship logs to both Loki and Elasticsearch during the migration. Train the team on LogQL while the old system is still available.
  • Identify queries that depend on full indexing. Audit dashboards and runbooks. Decide which queries cannot move to Loki, and either accept the limitation or keep a smaller Elasticsearch for those queries.
  • Improve label hygiene before migration. Labels in Loki are not free — high cardinality causes problems — so pick a label set that is narrow enough to be cheap and wide enough to support your queries.
  • Migrate retention progressively. Start by sending only the newest day to Loki. Confirm query patterns work. Extend retention as confidence grows.

The migrations that fail typically jump straight to Loki for everything, hit a query that does not work the same way, and pull back. A staged migration with clear cutover criteria works better.

A Decision Lens

The shortest version of the comparison:

  • Volume is the dominant cost driver, and queries are operational? Loki.
  • Query flexibility on arbitrary fields is core to the product or the workflow? Elasticsearch.
  • The team already runs and likes one of the two? Stay with it until cost or capability forces the change.

Neither is universally correct. The mistake is picking one based on someone else's case study without checking your own query patterns and budget.


Deciding whether to move from Elasticsearch to Loki — or vice versa? We help teams pick log storage that matches their query shape and bill. scopeforged.com

Share this article

Related Articles

Need help with your project?

Let's discuss how we can help you build reliable software.