Signal9Signal9 — home
online
back to labs

Python: Parse a JSON Event Log

EasyDevOps10-20 min
The brief

A small automation task: parse a JSON event log with Python and report three numbers. Your input is /root/case/events.json, a JSON array of objects like {"user": "alice", "status": "ok"|"fail"}.

Write a Python script (e.g. /root/case/report.py) using the json module that writes three plain-text files, each just a number:

  • /root/case/total.txt — total number of events
  • /root/case/fails.txt — number of events whose status is fail
  • /root/case/unique.txt — number of distinct users

The dataset varies per session, so hard-coding the answer won't work. See /root/case/brief.txt.

What you'll do
  • Read a JSON file with Python's json module
  • Count records and filter by a field value
  • Count distinct values with a set
  • Write results to output files for a downstream step

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.