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:

# /etc/rsyslog.conf — forward everything to a remote collector over TCP *.* @@log-collector.internal:514

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:

PieceRole
ElasticsearchStores 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
KibanaThe 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 stackGrafana Loki
Indexes full log textIndexes only labels/metadata, not full text
Heavier resource footprintDeliberately lighter, cheaper to run at scale
Kibana for visualizationGrafana for visualization — often already in use for metrics

What Doesn't Change

Aggregation changes where you search, not how you read
Every skill from Chapters 1 through 7 still applies once logs are centralized — severity levels, status code categories, access/error log correlation by timestamp, the layered diagnostic approach from Chapter 5. Aggregation is a scale-and-search layer sitting on top of the exact same underlying log content, not a replacement for understanding what's actually in it.
Clock skew quietly breaks timestamp correlation once centralized
Every technique in this course that relies on matching timestamps across log sources depends on those timestamps actually being accurate. Once logs from many servers are pooled together, even a small clock discrepancy between two of those servers can make genuinely related events look minutes apart — or make unrelated events look suspiciously close together. Keeping every server's clock synchronized via NTP isn't a minor detail; it's what makes cross-server correlation trustworthy at all.

Hands-On Exercises

Exercise 1

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 solution
Exercise 2

Explain the core architectural difference between the ELK stack and Grafana Loki, and what real tradeoff that difference represents.

📄 View solution
Exercise 3

Explain 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 solution

Chapter 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:port for 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