Chapter 14: Logging and Light Observability
Friends, today we learn logging — the flight recorder for a server. When a request fails, you replay. In containers: stdout/stderr and docker logs, central searchable logs, journald/logrotate, and the primary path: CloudWatch Logs (AWS link). A short ELK mention. One paragraph on correlation IDs. Secrets in logs — never. Do not fear: generate → query last error → 5-line incident note.
मित्रांनो, आज आपण logging शिकूया — server साठी flight recorder. Request fail झाली की replay. Containers मध्ये stdout/stderr आणि docker logs, central searchable logs, journald/logrotate, आणि primary path: CloudWatch Logs (AWS link). ELK चा short mention. Correlation IDs एक परिच्छेद. Secrets log मध्ये — कधी नाही. घाबरू नका: generate → query last error → 5-line incident note.
दोस्तों, आज हम logging सीखेंगे — server के लिए flight recorder. Request fail हो तो replay. Containers में stdout/stderr और docker logs, central searchable logs, journald/logrotate, और primary path: CloudWatch Logs (AWS link). ELK का short mention. Correlation IDs एक पैराग्राफ़. Secrets log में — कभी नहीं. घबराओ मत: generate → query last error → 5-line incident note.
What you will learn in this chapter
- Container stdout/stderr and docker logs
- Why central searchable logs matter
- journald and logrotate basics
- CloudWatch Logs as the primary path
- Correlation IDs and a short incident note
Concepts in this chapter
- 14.1Why logs — flight recorder for the server
- 14.2stdout/stderr and docker logs
- 14.3Local OS logs — journald and files
- 14.4Primary path — CloudWatch Logs
- 14.5Log groups, streams and agents (conceptual)
- 14.6Searching — find the last error
- 14.7Correlation IDs — one paragraph that saves hours
- 14.8Light observability vocabulary
- 14.9Security and hygiene
- 14.10Anti-patterns
- 14.11Troubleshooting table
- 14.12Lab — generate, query, write the note
Review and practice
- ★14.11b Retention, cost awareness and lab hygiene
- ★14.11c From red metric to log line (glue with Chapter 13)
- ★14.11d Structured logging mini-example
The chapter recap is at the end of the last concept page.
Practice Tasks
Suppose we are on the DevOps team at Coupang, the e-commerce company, working from Seoul. Ji-woo Park leads the team, and we look after the rocket delivery tracker. Costs are counted in KRW. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Coupang is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.
0 / 12
Easy Read container logs
Why: Logs are the first place to look when a container misbehaves.
What to do: Show the last 100 log lines of the container rocket-delivery.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Find errors in a log
Why: grep shows only the lines that contain a word, so you find problems fast.
What to do: Show every line containing ERROR in /var/log/coupang/app.log.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Click Check answer.
Easy Pod logs
Why: Logs show what the app printed before it failed.
What to do: Show the last 100 log lines of pod rocket-delivery-7d9f in coupang-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Follow logs live
Why: Watching logs live while you test shows errors the moment they happen.
What to do: Follow the logs of rocket-delivery live, starting from the last 20 lines.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Get a shell inside a container
Why: Looking inside a running container helps you check files and env.
What to do: Open an interactive sh shell inside the running container rocket-delivery.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Open a throw-away shell
Why: A short-lived container is a safe place to test commands.
What to do: Start an interactive ubuntu:24.04 container with a terminal, run bash, and remove the container automatically when you exit.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Logs of one compose service
Why: In a stack you want the logs of one service only.
What to do: Show the last 50 log lines of the compose service api.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium See the last lines of a log
Why: New errors are at the end of a log file. You rarely need the whole file.
What to do: Show only the last 20 lines of /var/log/coupang/app.log.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Click Check answer.
Hard Logs of the crashed container
Why: In CrashLoopBackOff the useful logs belong to the previous run.
What to do: Show the logs of the previous (crashed) container of pod rocket-delivery-7d9f in coupang-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Hard Name the metric
Why: DORA metrics show how healthy the delivery process is.
What to do: Which four-letter metric measures the average time to restore service after an incident?
- Write down the facts or numbers the task gives you.
- Work it out step by step.
- Type only the final answer (one word or number) in the box.
- Click Check answer.
Hard Error budget in minutes
Why: An SLO turns into a concrete downtime budget the team can spend.
What to do: The SLO is 99.9% availability over a 30-day month. How many minutes of downtime are allowed? (30 days = 43200 minutes)
- Write down the facts or numbers the task gives you.
- Work it out step by step.
- Type only the final answer (one word or number) in the box.
- Click Check answer.
Hard Compose: wait for a healthy database
Why: The app crashes if it starts before the database is ready.
What to do: Write compose.yaml: db (mysql:8.0) with a healthcheck whose test is ["CMD", "mysqladmin", "ping", "-h", "localhost"] and interval 10s; app (image coupang/rocket-delivery:1.2.4) that depends_on db with condition service_healthy.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Ravi Sir's Cards: 33 revision, interview and comparison cards for this chapter · मराठी cards