Every running service writes logs, and at scale those logs turn into a cost problem. Most teams land on one of three backends: Grafana Loki, Elasticsearch, or Datadog Logs. They solve the same problem with very different designs, so the right choice depends on how you query logs and how much operational work you want to own.
The core trade-off: what gets indexed
Storage cost and query speed come down to one design decision: what the system indexes. Loki indexes only metadata labels and stores compressed log chunks in object storage like S3. Elasticsearch indexes the full text of every log line, which makes searches fast at the cost of more storage and RAM. Datadog indexes your logs for you as a managed service and bills per gigabyte ingested. Everything else in this comparison follows from those three designs.
Grafana Loki: labels instead of a full index
Loki treats logs the way Prometheus treats metrics. Each log line belongs to a stream identified by labels such as {service="api", environment="production", level="error"}. Only the labels are indexed. Raw log lines get compressed into chunks and stored on cheap object storage, so there is no schema management or heap tuning to babysit.
Agents like Promtail or Grafana Alloy ship logs from your hosts and containers. You query everything through LogQL in the same Grafana UI you already use for metrics. A typical query looks like this:
{job="nginx"} |= "error" | json | status >= 500
The query picks streams by label, filters content with |= or a regex |~, then parses JSON fields inline.
One limitation to plan around is that content searches scan streams instead of hitting an index, so broad ad-hoc searches over long time ranges run slower than in Elasticsearch. Loki also inherits Prometheus-style cardinality rules. Labels with thousands of unique values, like user IDs or request IDs, will cause real trouble. Loki is open source under AGPLv3 and free to self-host; you pay for the servers, object storage, and your own time.
Elasticsearch: full-text search for deep log analytics
Elasticsearch indexes the full content of every log document into an inverted index built on Lucene. That design buys fast full-text search across large log volumes, a mature query DSL alongside KQL and ES|QL, and strong aggregations for histograms and term counts. Kibana adds log exploration, dashboards, and alerting in one place.
The price is operational weight. A production cluster wants multiple nodes with generous RAM, and you have to manage mappings, heap, and shard counts or performance falls apart. Storage costs more than Loki because every word is indexed. On licensing, Elasticsearch added an AGPLv3 option in 2024 alongside its commercial terms, so read the license for your use case before deploying.
Datadog Logs: the zero-ops SaaS option
Datadog takes operations off the table completely. Agents ship logs to Datadog’s cloud, pipelines parse and enrich them, and you search everything from one UI next to metrics, traces, and APM. Setup takes minutes, and over 600 ready integrations cover most stacks without custom work.
The trade-off is the bill. Datadog Logs is priced per gigabyte of logs ingested, so cost grows in direct proportion to log volume. Infrastructure monitoring, APM, and custom metrics are billed separately on top of that. There is no self-hosted option, so you rent the platform for as long as you use it. Self-published bills from engineers commonly cite roughly $0.10 per GB of log ingestion, but rates and retention tiers change, so check Datadog’s official pricing before you budget.
Loki vs Elasticsearch vs Datadog Logs at a glance
| Area | Grafana Loki | Elasticsearch | Datadog Logs |
|---|---|---|---|
| Indexing | Labels only | Full text of every line | Managed full-text |
| Query language | LogQL | Lucene, KQL, ES|QL | Datadog log search syntax |
| Storage | Compressed chunks on object storage | Lucene segments on disk | Datadog cloud |
| Cost model | Self-hosted, AGPLv3 | Self-hosted or Elastic Cloud | SaaS, per GB ingested |
| Operations effort | Low | High | None |
| Best for | Kubernetes logs on a budget | Deep log analytics and search | Teams that want it to just work |
Cost and operational reality
At modest log volumes, a SaaS bill is often cheaper than an engineer’s time, which is why small teams start with managed services. But logs are one of the fastest-growing line items in an observability budget, so review retention policies and drop noisy debug logs before they are ingested.
Self-hosting flips the math. Loki’s storage footprint on object storage stays small because compression does the heavy lifting, and it runs on far less RAM than a comparable Elasticsearch cluster. Elasticsearch remains the heavyweight: fast full-text search paid for in nodes, RAM, and ongoing care. In both self-hosted cases the dominant cost is people time, not disks.
Which log tool should you choose?
- Choose Loki if you already run Prometheus and Grafana, your logs are mostly structured JSON, and storage cost matters. It is the natural fit for Kubernetes logging.
- Choose Elasticsearch if you need full-text search across log content, complex analytics, or security-style investigations, and your team can operate a cluster.
- Choose Datadog Logs if you want a managed platform with metrics and traces in one UI, and fast onboarding matters more than per-gigabyte cost.
- Watch out for high-cardinality labels in Loki, mapping and heap management in Elasticsearch, and runaway log volume in Datadog.
FAQ
Is Grafana Loki really free?
Yes. Loki is open source under AGPLv3 and free to self-host. You pay for the servers and object storage it runs on, plus the time to operate it. Grafana also sells Loki as a managed service through Grafana Cloud.
Can Loki replace Elasticsearch?
For label-filtered log workflows it can. It does not replace Elasticsearch for workloads that need fast full-text search across arbitrary log content or heavy aggregation analytics.
How is Datadog Logs priced?
Datadog Logs is priced per gigabyte of logs ingested, and retention choices affect the total. APM, infrastructure monitoring, and custom metrics are billed separately. Check Datadog’s official pricing page for current rates before committing.