Investigate production errors and failed overnight jobs
Last updated
Copy this prompt
Paste this into a general agent such as ChatGPT agent or Claude, then add your own inputs.
Help me run this UseCaseProof playbook: Investigate production errors and failed overnight jobs. The problem: When an alert fires or a scheduled job fails overnight, someone has to gather the logs, recent deploys and the last good run before they can even start thinking about a fix. On-call engineers spend the first part of every incident on that collection work, often half awake, and overnight batch failures can sit unnoticed until the morning report is wrong. How the agent should work: When an alert fires or a scheduled job fails overnight, an agent can pull the logs, recent deploys and the last successful run, then post a likely cause and suggested fix for the on-call engineer. It can apply a known, pre-approved fix; anything else waits for a human. There are two triggers that feed the same loop. A live error alert starts with traces and logs around the alert window plus the deploys and config changes just before it. A failed scheduled job starts with that job's logs, compared line by line with its last good run, then checks upstream data (late or empty input files, schema changes) and recent deploys. In both cases the agent matches what it found against your runbooks. If a runbook lists the fix as safe to automate, such as rerunning a job once after an upstream file arrives late, it can apply it and report what it did. Everything else is suggest-only: it posts its evidence, its best hypothesis with a confidence note, and the runbook step it would follow, then opens or updates the incident. Follow these steps: 1. Give the agent read-only access to logs, traces, job scheduler history and deploy history 2. Trigger it from your alerting tool and from failed-job events in your scheduler (cron, Airflow, a CI schedule or similar) 3. For failed jobs, have it compare the failing run with the last successful run and check upstream inputs and recent deploys 4. Ask for evidence-backed hypotheses: every claim links to the log line, deploy or diff it came from 5. Write down which runbook fixes are pre-approved for automation (for example, one rerun after a late input) and keep every other action suggest-only 6. Post findings in the incident channel or ticket, and open an incident when no runbook matches 7. Review each triage after the incident and fix the runbook or the prompt where the agent was wrong Human-approval checkpoint: Humans decide remediation for anything not on the pre-approved runbook list. The on-call engineer confirms the root cause before it goes in the postmortem. Any write action to production, data deletion or rollback needs explicit approval. A person reviews the list of automated fixes regularly and removes any that misfired. Guardrails: Agents can be confidently wrong about causes, so require evidence links and treat the hypothesis as a lead, not a verdict. Use read-only scopes by default; an automated rerun can double-process data if the job is not idempotent, so only allow reruns on jobs that are safe to repeat and cap them at one. Logs can contain secrets or personal data, so mask them before they reach the model. Do not let the agent silence or close alerts on its own. Suggested tools from this playbook (not ranked; check current features and pricing): Datadog Bits AI, PagerDuty AI, Claude Code with MCP servers, Airflow or Dagster alerts + an LLM, Custom agent. Do not send messages, move money, grant access, merge code, or take any irreversible action until I approve. If you need an input I have not provided, ask me instead of guessing.
The problem
When an alert fires or a scheduled job fails overnight, someone has to gather the logs, recent deploys and the last good run before they can even start thinking about a fix. On-call engineers spend the first part of every incident on that collection work, often half awake, and overnight batch failures can sit unnoticed until the morning report is wrong.
How the agent works
When an alert fires or a scheduled job fails overnight, an agent can pull the logs, recent deploys and the last successful run, then post a likely cause and suggested fix for the on-call engineer. It can apply a known, pre-approved fix; anything else waits for a human. There are two triggers that feed the same loop. A live error alert starts with traces and logs around the alert window plus the deploys and config changes just before it. A failed scheduled job starts with that job's logs, compared line by line with its last good run, then checks upstream data (late or empty input files, schema changes) and recent deploys. In both cases the agent matches what it found against your runbooks. If a runbook lists the fix as safe to automate, such as rerunning a job once after an upstream file arrives late, it can apply it and report what it did. Everything else is suggest-only: it posts its evidence, its best hypothesis with a confidence note, and the runbook step it would follow, then opens or updates the incident.
Setup steps
- Give the agent read-only access to logs, traces, job scheduler history and deploy history
- Trigger it from your alerting tool and from failed-job events in your scheduler (cron, Airflow, a CI schedule or similar)
- For failed jobs, have it compare the failing run with the last successful run and check upstream inputs and recent deploys
- Ask for evidence-backed hypotheses: every claim links to the log line, deploy or diff it came from
- Write down which runbook fixes are pre-approved for automation (for example, one rerun after a late input) and keep every other action suggest-only
- Post findings in the incident channel or ticket, and open an incident when no runbook matches
- Review each triage after the incident and fix the runbook or the prompt where the agent was wrong
Tools that can do this
- Datadog Bits AI
- PagerDuty AI
- Claude Code with MCP servers
- Airflow or Dagster alerts + an LLM
- Custom agent
Some tool links may be affiliate links. We only list tools that fit the playbook; recommendations are not sold. Disclosure.
Not ranked. Tools marked Featured pay for a highlighted listing; that never decides which tools we include. Check each vendor's current features and pricing.
Make one of these tools? Feature your tool on every playbook where it is already listed.
Human in the loop
Humans decide remediation for anything not on the pre-approved runbook list. The on-call engineer confirms the root cause before it goes in the postmortem. Any write action to production, data deletion or rollback needs explicit approval. A person reviews the list of automated fixes regularly and removes any that misfired.
Risks and guardrails
Agents can be confidently wrong about causes, so require evidence links and treat the hypothesis as a lead, not a verdict. Use read-only scopes by default; an automated rerun can double-process data if the job is not idempotent, so only allow reruns on jobs that are safe to repeat and cap them at one. Logs can contain secrets or personal data, so mask them before they reach the model. Do not let the agent silence or close alerts on its own.
ROI notes
Measure against your own baseline: time from alert to first useful triage note, how often the agent's suggested cause matched the confirmed root cause (false-cause rate), and how many overnight job failures were handled by a pre-approved fix. No vendor numbers are claimed here; track your own before and after.
Quick answers
How do I investigate production errors and failed overnight jobs?
When an alert fires or a scheduled job fails overnight, an agent can pull the logs, recent deploys and the last successful run, then post a likely cause and suggested fix for the on-call engineer. The full setup is 7 steps.
Do I need to code to set this up?
Some code is needed. We rate the setup Hard.
Which tools can do this?
Datadog Bits AI, PagerDuty AI, Claude Code with MCP servers, Airflow or Dagster alerts + an LLM, Custom agent. Not ranked; check each vendor's current features and pricing.
Where does a human stay in control?
Humans decide remediation for anything not on the pre-approved runbook list. The on-call engineer confirms the root cause before it goes in the postmortem. Any write action to production, data deletion or rollback needs explicit approval.
What's a starter prompt I can paste into ChatGPT agent or Claude?
A playbook-specific starter prompt is in the Copy this prompt section above. It is written from this playbook's steps and human-approval checkpoint, for a general agent such as ChatGPT agent or Claude.
Also useful: triage failed CI builds; open a fix PR from an issue; keep dependencies current; triage failed data quality checks; triage cloud cost anomalies.
Related playbooks
Get a first-pass review on every pull request
Reviewers are a bottleneck and miss routine issues.
Hand well-scoped issues to a coding agent
Small bugs and chores sit in the backlog because nobody has time.
Write missing unit tests for legacy code
Untested legacy code makes every change risky.
All AI agent examples, by function · More Software Engineering playbooks