CY6: Logging, monitoring and detection

Lesson 1 of 5 · reading 15–25 minutes; practice and project time is on the module page

What to log, and how

🎯You'll be able to

Choose which events to log, with which fields, and keep logs accurate, safe and available when they're needed.

🏠The everyday picture

A building's visitor book records who came in, when, whom they visited and when they left. It doesn't record what they said in the meeting, and it's kept somewhere a visitor can't tear out a page.

📘What it really is

📝A worked example

Input: AarogyaDesk's login and web logs in data/logs/auth.jsonl and data/logs/web.jsonl.

Steps:

  1. Read a login line: {"ts": "2026-10-26T03:40:00Z", "event": "login", "user": "S06", "ip": "198.51.100.10", "ok": false}.
  2. Check the fields: time in UTC, event, user, address, result. There's no password, which is right.
  3. Read a web line: it has the time, address, user, method, path, query and status code.

Expected output: a note saying the logs cover logins, role changes and record views, and what's missing (for example, logouts).

🌍Where it's used

📝Case scenario

After a suspected breach, a company found its web servers' clocks were 47 minutes apart and logs were kept for only 7 days. It couldn't put events in order or see how the intruder first got in. Clock sync and longer retention were the first fixes.

🖱️Try it

Open data/logs/auth.jsonl in the kit and find the first line that isn't valid JSON. Success: you can say what's wrong with it.

⚠️Common mistakes

🛠️For your project

Project 3 reads both log files and builds alerts and a timeline from them.

✅Quick check

Why record log times in UTC?

Show the answer

So events from different servers and places can be put in one order without confusion.

Name two things that should never be written to logs.

Show the answer

Passwords and session tokens (also full card numbers).

← BackCY6
ProLearners Assist