DEV Community

My read-only AI agent found 3 AWS root causes in seconds. Then I learned why it was never wrong.

Three CloudWatch alarms went red at the same time: an Amazon SQS queue, an AWS Step Functions workflow, and an AWS Lambda function.

The SQS one had no error. No exception, no log line, just a message that had been sitting in the queue for about 671 seconds. A read-only AI agent read that, named the cause (the consumer had stalled) and posted it as a GitHub issue in 2.1 seconds. All three causes took between 2.1 and 6.4 seconds.

Then I tried to fix the Lambda with the agent's own credentials:

AccessDeniedException ... is not authorized to perform: lambda:UpdateFunctionConfiguration
Enter fullscreen mode Exit fullscreen mode

That is the rule this build rests on: the agent finds, a human fixes. It has ReadOnlyAccess plus one Bedrock permission, and nothing else.

It looked like the model was diagnosing outages. When I read my own code again, I found that for two of the three incidents it was repeating an answer I had written for it. That part is below too.

This is the build log: Amazon Nova Pro in a Kiro Crew job, with Python doing the evidence gathering.

GitHub logo simplynadaf / incident-investigator

Read-only AI SRE: correlates a CloudWatch alarm into one cited root cause. Amazon Nova Pro phrases it, Python gathers the evidence, nothing gets changed. A Kiro Crew agent.

The Incident Investigator: break three AWS services at once (Amazon SQS backlog, AWS Step Functions bad deploy, AWS Lambda timeout), a read-only AI agent finds every root cause, a human approves each fix. Powered by Amazon Nova Pro as a Kiro Crew job.

🔍 Incident Investigator: a read-only AI SRE

Three different production services break at once. A read-only AI agent investigates each one, traces it from the CloudWatch alarm to the metric, to the log or the config, to the change that caused it, and names a single cited root cause plus the fix to run. It never remediates on its own. A human approves each fix, and the alarms recover.

Amazon Nova Pro Kiro Crew Read only Python gathers the evidence License: MIT

Most AI for incidents makes you faster at correlating signals, not at isolating the cause. This one commits to a single root cause with a confidence level, and tells you what it could not verify.


🏗️ Architecture

Three AWS services (Amazon SQS, AWS Step Functions, AWS Lambda) break and their CloudWatch alarms go red. A read-only Kiro Crew agent gathers evidence with deterministic Python (alarm and metric, CloudWatch Logs, resource config, CloudTrail change), Amazon Nova Pro phrases one cited cause, and a guard strips any uncited number. A human approves and applies each fix, and all three alarms recover to OK.

The flow is the same for every incident: break → alarm → investigate (read-only) → approve → fix → recover. The agent only ever reads. A human draws the line in production.


🤔 What it does

An alarm tells you something is wrong, not…


Why three services

My first version broke one Lambda and found one timeout. It worked and proved little. A tool that only understands Lambda errors is a Lambda-error parser.

A bad night on call does not hand you one clean error. It hands you a queue that stopped draining, a workflow that started failing after a deploy, and a function that got slower, sometimes with no error log at all. So I rebuilt it around three services that fail in three different ways.


Read-only, and you can check

The agent runs as an IAM user with the ReadOnlyAccess managed policy plus one inline policy, bedrock:InvokeModel on amazon.nova-pro-v1:0, so it can phrase what it found. Try to change something:

$ aws lambda update-function-configuration --function-name demo-ii-checkout-api \
    --timeout 10 --profile ii-readonly
An error occurred (AccessDeniedException) when calling the UpdateFunctionConfiguration
operation: User: arn:aws:iam::<account-id>:user/demo-ii-readonly is not authorized to
perform: lambda:UpdateFunctionConfiguration ... because no identity-based policy allows
the lambda:UpdateFunctionConfiguration action
Enter fullscreen mode Exit fullscreen mode

I ran that again before writing this post. An LLM should not rewrite production config on its own, and here it has no permission to.


How it works

Architecture: three AWS services break and their CloudWatch alarms go red. A read-only Kiro Crew agent gathers evidence with Python (alarm and metric, logs, resource config, CloudTrail), Amazon Nova Pro phrases one cause, a guard strips uncited numbers, and a human approves each fix.

harness/investigate.py reads the alarm's namespace and picks an evidence gatherer for that service:

def gather(alarm):
    ns = describe_alarm(alarm)["Namespace"]
    if ns == "AWS/SQS":    return gather_sqs(alarm)           # queue age + depth
    if ns == "AWS/States": return gather_stepfunctions(alarm) # failed runs + error
    return gather_lambda(alarm)                               # errors + log + config
Enter fullscreen mode Exit fullscreen mode

Python collects facts with read-only calls (Describe, Get, List, FilterLogEvents, CloudTrail LookupEvents), and adds a one-line signal that I wrote for each failure type. Keep that line in mind. Then Nova Pro, at temperature 0.2, writes three short sections from only that evidence: cause, confidence, fix. A guard then drops any line that contains a number of two or more digits that is not in the evidence. The script, not Nova, opens the GitHub issue.

The guard is narrow. It catches invented numbers, not invented words. Keep that in mind when you read the next section.


Three incidents, three signals

Service What I broke What the agent read Time to RCA
Step Functions deployed a failing workflow definition ExecutionsFailed = 172, error PaymentServiceUnavailable: downstream payment call failed 3.1 s
SQS left messages with no consumer oldest message ~671 s old, 20 visible 2.1 s
Lambda cut the timeout from 10 s to 1 s Errors = 303, timeout log line, Timeout=1, CloudTrail UpdateFunctionConfiguration 6.4 s

The alarms were: ExecutionsFailed above 0, oldest message age above 60 s, and Errors above 0.

SQS is the interesting one. Nothing throws. The only evidence is that the oldest message keeps aging, so a log-only tool sees nothing.

Kiro Crew terminal after the investigator ran on the SQS alarm, with a dialog showing the root cause: the consumer has stalled and messages are piling up, proposed fix named, the agent will not run it

Step Functions has no application log either. The agent read the failure count and the failed execution's error:

Kiro Crew terminal after the investigator ran on the Step Functions alarm, with a dialog showing the root cause: the recent workflow definition deployment, proposed fix named, the agent will not run it

Lambda had the most evidence, so it got the sharpest answer. This is the issue it posted:

ROOT CAUSE: The Lambda function "demo-ii-checkout-api" is timing out due to its configured timeout setting of 1 second, which is insufficient for the function to complete its execution.

CONFIDENCE: High, because the error log explicitly states "Lambda invocation ended with Status: timeout (hit the configured time limit)" and the signal indicates "invocations hit the time limit."

FIX (do not run, read-only): Increase the timeout setting for the Lambda function "demo-ii-checkout-api" to allow it sufficient time to complete its execution.

Kiro Crew terminal after the investigator ran on the Lambda alarm, with a dialog showing the root cause: the function is timing out at its 1 second setting, proposed fix named, the agent will not run it

Each run also opened a GitHub issue with the evidence timeline. The issues are public: Step Functions, SQS, Lambda.


A human applies each fix

The agent proposes and a person acts. In the demo, I ran one fix command per incident: restore the good Step Functions definition, purge the queue, restore the Lambda timeout. Each alarm went back to OK.

Two things about those fixes. The agent's own fix text was not always specific. For SQS it said "investigate and resolve the issue causing the consumer to stall." Draining the queue was my step, and it is a destructive one: purge-queue deletes every message. Fine for a demo queue, not something to run blind on a real payments queue.


It was right, partly because I told it

Before Nova Pro sees anything, each Python gatherer adds that one-line signal to the evidence. Here are the two I wrote for SQS and Step Functions, straight from harness/investigate.py:

# SQS: always ends the same way
"... and nothing is consuming them (messages sent but not deleted), so the consumer has stalled"

# Step Functions: always ends the same way
"... which points to the workflow definition itself, not the input, so a recent definition deploy is the likely cause"
Enter fullscreen mode Exit fullscreen mode

Both are fixed text. They appear whenever that gatherer runs, whatever the queue or the workflow is doing. So for two of the three incidents, Nova reported a cause my code had already stated. It was right because those are exactly the two things I broke. The Step Functions run had no CloudTrail change line at all, so the "recent deploy" came from my sentence, not from evidence.

Lambda is different. Its signal depends on what the logs show: a timeout line produces "invocations hit the time limit (points to the timeout setting)", an out-of-memory line produces a memory signal, and so on. That answer also had Timeout=1 from the config and the CloudTrail UpdateFunctionConfiguration event behind it.

So the honest result is this. Python rules did most of the diagnosis, and Nova turned the evidence into a readable cause, confidence and fix. The rules are the part you can test, which is why I built it this way. But on a real incident, the SQS rule would blame a stalled consumer for any SQS alarm, whatever the actual cause. The fix is to make every signal depend on evidence, the way the Lambda one does.


Where it is weak

  • Two of the three signals are hard-coded (see the section above). Until they depend on evidence, the SQS and Step Functions answers are only as good as my guess about what broke.
  • It is three incidents, one recorded take. This is a demo of a pattern, not a benchmark. I have no hit rate to quote.
  • The incidents are small and clean on purpose, so you can reproduce them. A novel outage still needs a human.
  • The guard only checks numbers. It does not catch a wrong service name or a wrong verb.
  • I measured wall-clock only (2.1 to 6.4 seconds per RCA). I make no MTTR claim, and I did not measure the bill. The services ran about 20 to 30 minutes per take, and the whole stack is small: one queue, one function, one state machine, three alarms.

Run it yourself

git clone https://github.com/simplynadaf/incident-investigator ~/incident-investigator
cd ~/incident-investigator
python3.11 -m venv .venv && .venv/bin/pip install boto3

bash infra/setup_3services.sh     # SQS + Step Functions + Lambda + 3 alarms
bash infra/setup_readonly.sh      # read-only identity, Bedrock invoke, proves a write is denied

bash infra/incidents3.sh break fulfillment
bash infra/incidents3.sh break payments
bash infra/incidents3.sh break checkout

AWS_PROFILE=ii-readonly python3 harness/investigate.py --alarm demo-ii-fulfillment-failures --post
AWS_PROFILE=ii-readonly python3 harness/investigate.py --alarm demo-ii-payments-backlog --post
AWS_PROFILE=ii-readonly python3 harness/investigate.py --alarm demo-ii-checkout-errors --post

bash infra/incidents3.sh fix fulfillment   # a human approves each fix
bash infra/incidents3.sh fix payments
bash infra/incidents3.sh fix checkout

bash infra/teardown_3services.sh           # clean up
Enter fullscreen mode Exit fullscreen mode

You need gh logged in, AWS credentials, and Bedrock access to amazon.nova-pro-v1:0 in us-east-1. As a Kiro Crew job, the message is the config: {"alarm": "demo-ii-checkout-errors", "post": true}. The SQS alarm takes a few minutes to go red, so give it time before you investigate.


Your turn

Would you let an AI agent post a root cause to your on-call channel before a human asks it to look? I will reply to every comment.

Drafted with AI help. Every output, number and timing above comes from my own run logs and AWS responses. The agent finds, a human fixes.


Follow me for more on AWS architecture, DevOps, and AI Infrastructure:
Portfolio | LinkedIn | Dev.to | YouTube | Email | AWS Builder Center | X

Top comments (1)

Collapse
 
smtahosin profile image
S M Tahosin •

The honesty about the hard-coded signals is what makes this post work. Most write-ups would have stopped at "3 root causes in seconds". On your question: yes, I'd let it post to the on-call channel, but only if every claim in the message points at a raw evidence line a tired human can check in ten seconds. The numbers-only guard is the seam I'd worry about. A wrong function name or a wrong verb sails straight through it, and at 3am nobody re-reads carefully. Checking that every identifier in the answer appears verbatim in the evidence would catch most of that. Does the GitHub issue include the raw evidence, or only the phrased summary?

Some comments may only be visible to logged-in visitors. Sign in to view all comments.