ScriptsApr 10, 2026·3 min read

Grafana Loki — Prometheus-Inspired Log Aggregation System

Loki is a horizontally scalable, multi-tenant log aggregation system by Grafana Labs. Unlike other log systems, Loki indexes metadata about logs, not log content itself.

TL;DR
Loki indexes log metadata instead of full text, making it far cheaper than traditional log systems like ELK.
§01

What it is

Grafana Loki is a horizontally scalable, multi-tenant log aggregation system inspired by Prometheus. Built by Grafana Labs, Loki takes a distinct approach to log management: it indexes only labels (metadata) rather than the full text of every log line. This makes storage and indexing dramatically cheaper than systems like Elasticsearch that index all content.

Loki targets DevOps and SRE teams already using Prometheus and Grafana for metrics who want a unified observability stack. It integrates natively with Grafana dashboards and uses a query language called LogQL that mirrors PromQL syntax.

§02

How it saves time or tokens

By indexing only labels, Loki reduces storage costs to a fraction of what Elasticsearch or Splunk requires. Promtail, the log collector agent, automatically attaches Kubernetes labels to log streams, eliminating manual log parsing configuration. LogQL lets you filter, aggregate, and create alerts from logs using the same patterns you already know from PromQL.

§03

How to use

  1. Run Loki as a Docker container: docker run -d --name loki -p 3100:3100 grafana/loki:latest.
  2. Deploy Promtail as a log collector that ships log streams to Loki from your application servers or Kubernetes nodes.
  3. Add Loki as a data source in Grafana at http://localhost:3100 and query logs using LogQL.
§04

Example

# Docker Compose for Loki + Promtail
version: '3'
services:
  loki:
    image: grafana/loki:latest
    ports:
      - '3100:3100'
  promtail:
    image: grafana/promtail:latest
    volumes:
      - /var/log:/var/log:ro
      - ./promtail-config.yml:/etc/promtail/config.yml

LogQL query examples:

{job="nginx"} |= "error"
{namespace="production"} | json | status >= 500
rate({job="api"}[5m])
§05

Related on TokRepo

§06

Common pitfalls

  • Loki does not index log content, so full-text search across large time ranges is slower than Elasticsearch; use label filters to narrow the scope first.
  • High-cardinality labels (like user IDs or request IDs) cause performance degradation; keep label sets small and consistent.
  • Promtail requires explicit configuration for non-Kubernetes log sources; file paths and parsing rules must be defined manually.

Frequently Asked Questions

How does Loki compare to the ELK stack?+

Loki indexes only metadata labels while Elasticsearch indexes full log text. This makes Loki cheaper to run and simpler to operate, but full-text search is slower. Loki is best when you have structured labels and use Grafana for visualization.

What is LogQL?+

LogQL is Loki's query language, modeled after PromQL. It supports label matchers, line filters, parsing pipelines, and aggregation functions. If you know PromQL, LogQL syntax will feel familiar.

Can Loki handle production-scale log volumes?+

Yes. Loki scales horizontally by separating read and write paths. Each component (ingester, querier, compactor) can be scaled independently. Many organizations run Loki with terabytes of daily log ingestion.

Does Loki support alerting?+

Yes. Loki includes a ruler component that evaluates LogQL alerting rules and sends notifications through Alertmanager, the same tool used for Prometheus alerts.

What log collectors work with Loki?+

Promtail is the primary collector, but Loki also accepts logs from Fluentd, Fluent Bit, Vector, and any client that speaks the Loki HTTP push API.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets