HANDS-ON TASK · 1 OF 1

Log analyzer CLI

Project: Log analyzer CLI

You are an SRE at esc bash. Every service on the fleet writes a plain text log, and when something breaks the first question is always the same - how many warnings and errors are in here, and how bad is it? Reading the file by eye does not scale. Build a small Go tool that turns a log into a level by level summary you can drop into a report or an alert.

Set up the project

Run this first. It seeds the input file for the task:

bash
curl -fsSL https://raw.githubusercontent.com/Esc-Bash/project-init-scripts/main/go/project-1/init.sh | bash

This creates /root/mission/app.log and the /root/answers folder. Every line starts with a timestamp, then a log level, then a message, for example:

2026-07-24 10:00:07 INFO request handled ok

The level is always one of DEBUG, INFO, WARNING, ERROR, or CRITICAL.

What to build

Create a Go module at /root/loganalyzer with a main.go. The program reads /root/mission/app.log, pulls the level out of each line, counts how many lines carry each level, and writes the result to /root/answers/summary.json as JSON with this exact shape:

{
  "total": <number of log lines with a level>,
  "levels": {
    "DEBUG": <count>,
    "INFO": <count>,
    "WARNING": <count>,
    "ERROR": <count>,
    "CRITICAL": <count>
  }
}

Read the file the way the files topic covered, count with a map, and build the JSON with encoding/json so the shape is always valid. Run your program so that it writes /root/answers/summary.json, for example:

cd /root/loganalyzer && go run .

Press Submit when the summary is written and the counts are correct.

Start the lab on the right to run checks.

Pass the checks to continue
Spin up a fresh environment and practice live.
go · fresh machine · ready in under a minute