>_ IzzyLab

Hands-on task

This task is step 12 of the course “Logs: analysis and housekeeping”

What happened before the first error

hard~12 min

There are two logs for the same morning: /var/log/ops.log — operations actions (TIME event), and /var/log/http.log — service responses (TIME CODE text). Find the last action in ops.log that happened before the first 5xx error in http.log and write its text (without the time) to /root/cause.txt.

What you'll practise:
  • awk
  • log correlation
  • time comparison
  • -v variable passing
  • END block

Topic breakdown

Correlating events from different logs is a basic incident analysis technique: first you find the reference point (the first error), then you look for the closest preceding event in the other log. Technically this takes a single awk pass: a variable updated on every matching line, and its value printed in the END block, which runs after the end of input. Times in a zero-padded format (HH:MM:SS) compare correctly as strings, which saves converting them to seconds; for formats without leading zeros or with different time zones this no longer works.

What's checked

  1. the correct root-cause event was found

What it looks like