PagerDuty On-Call Incident Investigator
Authenticate, list escalation policies, fetch all incidents and their details, then analyse relevance across Envato on-call teams.
Arguments
- — (optional) Start date in format. Defaults to today's date.
- — (optional) End date in format. Defaults to today's date.
Target Escalation Policies
The list of escalation policies to investigate is resolved in order:
- — array in config.json
- — comma-separated env var (e.g.
"Elements On Call, Platform Engineering (GPET) On-Call"
)
- If both are empty, all escalation policies are included
System Requirements
- CLI installed (https://github.com/martindstone/pagerduty-cli)
- available on PATH
- Environment variable set with a valid PagerDuty REST API token
Output Directory
All intermediate JSON and the final report are saved to:
.pagerduty-oncall-tmp/
├── ep-list.json # Parsed escalation policies
├── incidents.json # Parsed incident list (filtered by target EPs)
├── logs/<INCIDENT_ID>.json # Parsed log per incident
├── notes/<INCIDENT_ID>.json # Parsed notes per incident
├── analytics/<INCIDENT_ID>.json # Parsed analytics per incident
├── summary.json # Execution summary (counts, errors)
└── report.md # Final analysis report
Execution
1. Fetch All Data
Run the single fetch script. It handles authentication, EP listing, incident listing, and gathering logs/notes/analytics for each incident — all sequentially to avoid PagerDuty API rate limits.
bash
node scripts/fetch-pd.js .pagerduty-oncall-tmp $ARGUMENTS[0] $ARGUMENTS[1]
If this fails with an authentication error, use
to inform the user and link to the
PagerDuty CLI User Guide for setup instructions. Do NOT continue until the script succeeds.
2. Analyse and Report
Read
first to understand the scope. Then read
and all files from
,
, and
subdirectories using the Read tool.
Produce a structured analysis and save it using Write to
.pagerduty-oncall-tmp/report.md
:
- Incident Summary Table — For each incident: ID, title, service, escalation policy, status, urgency, created/resolved timestamps (user's local time, not UTC), duration
- Cross-Team Correlation — Identify incidents that overlap in time across different escalation policies. Flag potential cascading failures or shared root causes
- Timeline — Chronological view of all incidents across all teams in user's local time, highlighting clusters of activity
- Key Findings — Patterns, recurring services, repeated triggers, or escalation policy gaps
- Recommendations — Actionable suggestions based on the analysis
After writing the report, inform the user of the report location:
.pagerduty-oncall-tmp/report.md
<tags>
<mode>think</mode>
<custom>yes</custom>
</tags>