# Incident Timeline Builder

> Turn incident logs from many files and time zones into one UTC timeline where every row cites its file:line. Code computes the incident window and time to detect, acknowledge, mitigate and resolve, then drafts a blameless postmortem whose every timestamp is an evidence row. Python stdlib only.

Incident Timeline Builder is a paid AI agent skill on Agensi by Hale Sinclair, in DevOps & Cloud. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5 (one-time purchase)
- Creator: [Hale Sinclair](https://www.agensi.io/creators/hale-sinclair)
- Category: [DevOps & Cloud](https://www.agensi.io/skills/devops-cloud)
- Version: 1.0
- Last updated: 2026-12-01
- Security: scan passed (2026-12-01); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/incident-timeline-builder
- Tags: devops, testing, documentation, postmortem, incident, sre, on-call, logs

## About this skill

### The problem
After an outage the evidence is spread across files that do not agree on time:
- the proxy's access log has an offset in every line;
- its error log and the app log have local time and no zone;
- BSD syslog has no year;
- the chat export has only `[17:40]`.
Lining these up by hand is slow and easy to get wrong by a whole hour. A postmortem written from memory or a pasted excerpt gets the start time, the time to detect and the order of events wrong. Nobody can check where a time came from.

### What it does
Three standard-library Python scripts do the measurable part. Your agent does the judgment part.
- **timeline.py** reads each evidence file and works out its format. It converts every time to UTC: from the offset in the line, or from the zone you give per file with `--file-tz`. It merges all files into one timeline in UTC order: events.csv, events.jsonl, timeline.md with the notable rows, and summary.json.
  - Every row keeps its `file:line` and the text as it stands in that line.
  - Python tracebacks and Java stack traces are folded into their row. The exception line is kept with its own line number.
  - When a file's zone is not given, a zone check warns that the file's times line up with the other files only at another offset, and names that offset.
- **window.py** finds the incident window from the per-minute 5xx share against a median baseline (a minute counts as bad only with 3 or more 5xx rows, so one stray 500 does not stretch the window). It names the start, peak and end rows and the alert, acknowledgement and resolution rows. It computes time to detect, acknowledge, mitigate and resolve, and the impact duration, and writes them with their rows to window.json.
- **postmortem.py** turns window.json into a blameless postmortem draft: Impact, Detection and response, Timeline, Error signal per minute, the trigger candidate, then 5 whys, actions and lessons for the author to fill.
The agent then reads the rows it will cite, confirms or rejects the trigger, and writes the summary, causes and action items. It never writes a time or a number that is not in the scripts' output.

Formats read: nginx/Apache combined and common access logs, nginx error_log, syslog (RFC 3164, RFC 5424, rsyslog high-precision), JSON lines (`@timestamp`, ISO or epoch, pino, docker json-file), ISO-timestamped logs (Python logging, Java/logback, PostgreSQL, Kubernetes CRI) and `[HH:MM] name: text` chat exports (12- or 24-hour). `.gz` files work.

### What the check run proves
Here code reads the logs and does the time arithmetic, not the model, and the check run proves the results on a staged incident: a fault injected into real local processes, recorded as they logged it. 6 files, 31,211 rows, five zones plus UTC.
- **Every row traceable.** All 31,211 rows were checked against their own file:line: 0 mismatches. The 2,098 folded exception lines were checked at their own line numbers too. Every time in the postmortem draft is a row in the timeline with that UTC time.
- **Zones done by code, and checked.** Times written in Berlin, New York, Kolkata, Tokyo and Los Angeles land on the UTC that GNU `date` computes from the raw line. They also agree with the producing script's own clock: the deploy row is within 0.01 s of it, the whole-second rows within 1 s. With the zones left out, the zone check named the missing offsets: app.log at -05:00 and error.log at +01:00.
- **Counts that match the raw files.** The rows per file equal a grep/wc count of the file (13,946 / 1,226 / 15,947 / 14 / 72 / 6), with 0 unparsed lines. 14,686 traceback lines were folded.
- **The window matches the fault.** The fault was injected by deploying 2.4.1 at 01:37:27.539 and rolling back, which finished at 01:41:10.156. The window found was 01:37:27 to 01:41:10, inside a 2 s tolerance. The metrics equal the values computed by hand from grep, awk and GNU date: detect 101.043 s, acknowledge 51.957 s (±1 min, chat time), mitigate 223 s and resolve 250.544 s. The peak was 01:40 with 76.6 % 5xx (932 of 1,217).
- **Large logs.** 115.7 MB of logs (837,004 rows) were merged in under a minute with 21 MB peak memory (35.3 s on the test machine; the check requires under 120 s and 100 MB). The files are streamed, not loaded.
- **More formats.** 23 hand-written lines in 10 more formats came out right: UTC time, level and markers. They include nginx error_log across the US DST change, BSD syslog across New Year, a gzipped Java log with "Caused by" and a 12-hour chat crossing midnight.

### How it works
1. The agent lists the files you gave and asks which zone each zoneless file was written in.
2. `timeline.py FILES --file-tz app.log=America/New_York ... --out incident-out` merges them. The agent reads what it prints: rows, folded and unparsed lines per file, and any zone-check or inferred-year notes.
3. `window.py incident-out --out incident-out` prints and writes the window and the metrics. You can override the start, end, detected, acknowledged or resolved time with a file:line from the timeline.
4. `postmortem.py incident-out --title "..." --out incident-out` writes the postmortem draft from them.
5. The agent opens the rows it will cite, confirms or rejects the trigger candidate, and fills in the draft. It uses references/postmortem-guide.md for blameless wording, the 5 whys and action items.
Python 3.9+ standard library only. The scripts make no network calls, start no programs, run nothing from the logs, read only the files you name and write only to the output directory given with --out (without it they print). Each script is a single file that needs no other file of the package, so it runs the same when the agent writes it to a temporary file, as Agensi delivers scripts.

### Use cases
- Draft a blameless postmortem from last night's logs and chat export.
- Merge logs from servers in different time zones into one UTC timeline.
- Answer "when did it start, when did we notice, when did it end?" with the rows that prove it.
- Compute time to detect, acknowledge, mitigate and resolve for an incident report.
- Find the deploy or config change just before the errors began.

### Known limitations
- A line with no zone is read in the zone you give for its file (default UTC). The zone check needs 20 or more rows in that file and zoned rows in the other files, so a short chat export or a 10-line syslog is not checked.
- The window comes from the per-minute 5xx share (from error rows when there are no access logs) against the median minute. When the logs cover only the incident, every minute is bad and no window is found: give `--threshold` (or `--start` / `--end`).
- A minute needs 3 or more signal rows to count as bad (`--min-rows` changes it), so on very low traffic a real but thin error stretch can be missed.
- In the hour a fall-back repeats, a zoneless time could be either reading; rows that come after rows reading later are placed in the second hour by file order, and timeline.py prints a note saying how many.
- Chat times have minute precision, so metrics that rest on them carry ±1 min.
- Kubernetes CRI partial lines (`P`) are separate rows, not joined.
- Markers (deploy, alert, ack, rollback) are keyword hints. The trigger is a candidate until a row confirms it.
- It reads text logs only, not dashboards, traces or screenshots, and it is for after an incident, not live response.

## Requires

- Python

No accounts, API keys or services. Python 3.9+ on the machine.

## Known limitations

Lines with no zone are read in the zone given for their file (default UTC). The zone check that catches a wrong zone needs 20+ rows in the file, so short chat exports and tiny syslogs are not checked. The window needs a 5xx or error signal and quiet minutes to compare with; logs that cover only the incident need --threshold or --start / --end. A minute needs 3+ signal rows to count as bad (--min-rows). Zoneless rows in a repeated fall-back hour are placed by file order, with a note. Chat times are minute-precision (metrics marked ±1 min). Kubernetes CRI partial lines are not joined. Markers are keyword hints, and the trigger is a candidate until a row confirms it. Text logs only; not for live incidents.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Incident Timeline Builder skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### My app log has no time zone in it. What happens?

Give it with `--file-tz app.log=America/New_York` (or a fixed offset such as -05:00). If you leave it out, the file is read as UTC. When the file has 20+ rows, a zone check compares its per-minute activity with the zoned files and names the offset at which they line up. In the test run it named -05:00 for the New York app log and +01:00 for the Berlin error log.

### How do I know a time in the postmortem is real?

Every row carries file:line, and every time in the draft is one of those rows. `sed -n 'LINEp' FILE` shows the original line. The check run verified all 31,211 rows of the test incident against their lines.

### How big can the logs be?

The files are streamed and merged, not loaded whole. In the check run, 115.7 MB (837,004 rows) took 35.3 s with 21 MB peak memory. Your time depends on your machine.

### Does it decide the root cause?

No. It names the change just before impact as a trigger candidate and gives the rows. Your agent confirms or rejects it from the evidence and writes the 5 whys, with every answer tied to a row or marked unknown.

### Does any log data leave my machine?

The scripts make no network calls and only read the files you name. Your agent reads the rows it cites, as it would read any file you give it.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
