When a payment fails at 11 p.m., the first question is always the same: what happened? Metrics tell you that error rates jumped. Logs tell you why. If those logs are scattered across twenty servers and a hundred short-lived containers, finding the one line that matters can take longer than fixing the bug.
The short answer: centralised logging means collecting logs from every server, container and service into one searchable place. A typical setup has three parts: a shipper on each machine (such as Fluent Bit or Filebeat), a store that indexes the logs (such as Elasticsearch, OpenSearch or Grafana Loki), and a UI to search them (Kibana, OpenSearch Dashboards or Grafana). Learn to write structured logs and search them well, and you can debug production much faster.
Logging sits alongside metrics in the monitoring part of any practical DevOps training in Pune. This guide explains how a logging pipeline works, how the main stacks differ, and what good logs look like.
Why logs on each server stop working
On a single server, tail -f /var/log/app.log and grep go a long way. Add a load balancer and four app servers, and a single user’s request could be on any of them. Move to Kubernetes, and a crashed pod takes its logs with it when it is replaced.
Central logging fixes both problems. Every line is shipped off the machine as soon as it is written, tagged with where it came from, and kept for a set number of days. You search once, across everything, and the logs survive after the container is gone.
The three parts of a logging pipeline
1. Collect and ship
A small agent runs on each node and reads log files or container output. In Kubernetes it usually runs as a DaemonSet, one copy per node, reading from /var/log/containers. Fluent Bit is popular because it is light; Filebeat, Vector and the OpenTelemetry Collector do the same job. The agent adds labels such as host, namespace, pod and app name before sending each line on.
2. Store and index
The store is where the stacks differ most. Elasticsearch and its open-source fork OpenSearch index the full text of every log line, so searches are fast and flexible, but storage and memory costs grow quickly. Grafana Loki indexes only the labels and keeps the log text compressed, which is far cheaper to run, at the cost of slower full-text searches.
3. Search and visualise
Kibana sits on top of Elasticsearch, OpenSearch Dashboards on OpenSearch, and Grafana on Loki. From the UI you filter by app, time range and level, follow a request across services, and build dashboards or alerts from log patterns, such as a spike in status=500 lines.
ELK, EFK or Loki: which stack?
- ELK (Elasticsearch, Logstash, Kibana): the classic stack. Logstash is powerful for parsing and transforming logs but heavy to run.
- EFK: the same idea with Fluentd or Fluent Bit replacing Logstash, which is common in Kubernetes because the shippers are lighter.
- PLG / Loki stack: Promtail or another agent, Loki and Grafana. Popular with teams already using Prometheus and Grafana, since logs and metrics live in the same UI.
- Managed services: CloudWatch Logs, Azure Monitor Logs and Google Cloud Logging remove the need to run the store yourself, and many companies use these in production.
If you already know Grafana from our Prometheus and Grafana for beginners guide, Loki is the easiest place to start. Many job descriptions still mention ELK, so it is worth understanding both.
What a good log line looks like
Compare these two lines from the same failed payment:
2026-12-05 23:04:11 ERROR payment failed
{"time":"2026-12-05T23:04:11Z","level":"error","service":"payments",
"msg":"payment failed","order_id":"A1029","request_id":"7f3c9a",
"gateway":"upi","status":502,"duration_ms":3012}
The first tells you something broke. The second is structured, written as JSON, so the log store can filter on any field. You can find every failure for one order, every slow request over three seconds, or every error from one gateway, without writing fragile regular expressions.
The request_id field matters most. If every service passes the same ID along and includes it in its logs, one search shows a request’s whole journey across the system. This is the bridge between logging and distributed tracing.
Log levels and what not to log
Use levels consistently. ERROR is for things that need attention, WARN for something unusual that recovered, INFO for normal business events such as an order created, and DEBUG for detail you switch on only while investigating. Production noise usually comes from INFO lines that should have been DEBUG.
Never log passwords, API keys, full card numbers, Aadhaar numbers or other personal data. Logs are copied to many places and kept for weeks, so a leaked secret in a log line is a real security incident. Mask sensitive fields in the application or in the shipper before they leave the machine.
Searching logs: a few real queries
# Loki (LogQL): errors from the payments app in the last hour
{app="payments"} |= "error"
# Loki: parse JSON and keep only slow requests
{app="payments"} | json | duration_ms > 2000
# Kibana (KQL): failed UPI payments
service:"payments" and level:"error" and gateway:"upi"
Even without a central system, the same thinking works on one machine. journalctl -u nginx --since "1 hour ago" and grep are worth knowing well; our guide to Linux for DevOps covers them.
Retention and cost
Logs grow fast. A busy service can write gigabytes a day, and keeping everything forever is expensive. Teams usually keep detailed logs for 7 to 30 days, archive older logs to cheap object storage such as S3, and drop noisy DEBUG lines at the shipper. Deciding retention early saves a painful surprise on the cloud bill later.
A weekend practice project
Start a local Kubernetes cluster with kind, install Loki and Grafana with their Helm charts, and deploy a small app that writes JSON logs. Open Grafana, find your app’s logs by label, then write a LogQL query that shows only errors. Finally, delete a pod and confirm its logs are still searchable. That last check is the whole point of centralised logging, and it is a good story to tell in an interview.
Frequently asked questions
What is the difference between logs, metrics and traces?
Metrics are numbers over time, such as requests per second or CPU use. Logs are individual events with detail. Traces follow one request across several services. Together they are often called the three pillars of observability.
Should I learn ELK or Loki first?
If you already use Grafana, start with Loki because it is simpler to run. Learn the basics of Elasticsearch and Kibana too, since many companies and job descriptions still use the ELK stack.
Do I need centralised logging for a small project?
For one server, local logs and journalctl are often enough. Once you have several servers or any containers, central logging quickly pays for itself.
Is Fluentd the same as Fluent Bit?
They come from the same project. Fluentd has more plugins and processing features; Fluent Bit is smaller and faster, which makes it the usual choice as an agent on each node.





