Log Pipeline with Loki
Centralize logs from multiple services with structured queries.
0 of 6 steps
What you will end up with
Centralized log aggregation
Structured, queryable logs
Log-based alerts
Build steps
0/6Run Loki as the storage and query backend, with Promtail on each host tailing log files and shipping them over. Loki is the filing cabinet, Promtail is the intern walking pages over to it.
Have your app log JSON lines instead of plain text, like level, msg, and a timestamp on every entry. Structured logs are pre-labeled folders instead of a shoebox full of loose receipts.
Configure Promtail to attach labels, like app or environment, to every log stream it ships. Labels are the sticky notes on the filing cabinet drawers so you can find things fast later.
Add Loki as a data source in Grafana and use LogQL, something like app=“api” then filter for the word error. It reads like a search bar: show me lines from this app containing this word.
Put a Loki panel next to a Prometheus panel on the same dashboard, synced to the same time range. Now a spike on the metrics graph and the matching log lines sit side by side.
Configure a Loki ruler alert that fires when a pattern, like a crash message, appears more than a few times in a window. It is a smoke detector tuned to one specific word instead of actual smoke.
Before you start