Log Aggregation & Centralized Logging
Logging & Log Analysis
Chapter 8 · Log Aggregation & Centralized Logging
Chapters 6 and 7 both worked because everything lived on one server, or a small enough handful that checking each one by hand was realistic. This chapter is a conceptual orientation to what happens once that stops being true — not a deep implementation guide, but enough to recognize the pieces and know what they're for.
The Problem: When "SSH Into Each Server" Stops Working
Two things break the manual approach as a system grows:
- Scale. Checking one server's logs by hand is fine. Checking the same thing across dozens or hundreds of servers, one at a time, isn't — the time cost alone makes it impractical during an active incident
- Ephemerality. In containerized and cloud environments, individual containers or instances are routinely destroyed and replaced rather than kept running indefinitely. A log that only exists on a container that no longer exists is a log that's gone permanently — Chapter 1's "silent failure" problem, but caused by the infrastructure itself rather than a missing log statement
The Core Idea: Ship Logs Somewhere Central
Rather than leaving each log where it was generated, a copy is forwarded to a central location as it's written. This solves both problems at once: one place to search instead of many, and logs that outlive the server or container that produced them.
syslog & rsyslog Forwarding
The syslog protocol Chapter 2 already introduced was designed to support forwarding to a remote collector, not just writing to a local file. rsyslog, the syslog daemon most Linux distributions actually run today, can be configured to forward matching log entries to a remote server with a small addition to its own config:
The double @@ specifically means TCP (a single @ means UDP) — a small syntax detail, but one worth getting right, since UDP forwarding can silently drop log messages under load with no error at all.
A Conceptual Tour: The ELK Stack
One of the most common centralized-logging stacks in real production use, built from three (or more) cooperating tools:
| Piece | Role |
|---|---|
| Elasticsearch | Stores and indexes the log data, making it searchable |
| Logstash (or Filebeat/Fluentd) | Collects and ships logs from each source into Elasticsearch, often reshaping them along the way |
| Kibana | The web UI for searching, filtering, and visualizing what's in Elasticsearch |
A Conceptual Tour: Grafana Loki
A more lightweight alternative, built around a genuinely different tradeoff: rather than indexing the full text of every log line the way Elasticsearch does, Loki indexes only a small set of labels (like which service or server a log came from), storing the actual log text compressed and unindexed. That's a real, deliberate resource-usage tradeoff — cheaper to run at scale, at the cost of full-text search being somewhat less immediate than in an ELK-style setup. Promtail is Loki's typical log-shipping agent, and Grafana — already familiar to many teams from metrics dashboards — is the usual way to query and view Loki's own data.
| ELK stack | Grafana Loki |
|---|---|
| Indexes full log text | Indexes only labels/metadata, not full text |
| Heavier resource footprint | Deliberately lighter, cheaper to run at scale |
| Kibana for visualization | Grafana for visualization — often already in use for metrics |
What Doesn't Change
Hands-On Exercises
Explain the two separate problems this chapter says log aggregation solves, and why "just SSH into each server" stops being a workable answer to either one as a system grows.
📄 View solutionExplain the core architectural difference between the ELK stack and Grafana Loki, and what real tradeoff that difference represents.
📄 View solutionExplain why clock skew between servers becomes a real problem specifically once logs are centralized, using techniques this course already covered in earlier chapters as part of your answer.
📄 View solutionChapter 8 Quick Reference
- Manual per-server log checking breaks down for two reasons: scale (too many servers to check by hand) and ephemerality (containers/instances that no longer exist)
- rsyslog can forward logs to a remote collector —
@@host:portfor TCP, a single@for UDP (which can silently drop messages under load) - ELK stack: Elasticsearch (storage/search) + Logstash/Filebeat (shipping) + Kibana (visualization) — indexes full text
- Grafana Loki: indexes labels only, not full text — lighter, cheaper, paired with Grafana
- Aggregation doesn't change what you're reading or how you read it — every earlier chapter's skills still apply directly
- Synchronized clocks (NTP) matter more, not less, once correlating logs across many servers centrally
- Next chapter: Writing to Logs — Existing Files vs. Custom Log Files