AWS Builder Center
Weekend Annoying Task Challenge: OpsPilot

Weekend Annoying Task Challenge: OpsPilot

An AI-Powered AWS Incident Investigator

Cloud Engineer - AWS

Every CloudWatch Alarm Started the Same Way . . .

If you've ever worked with AWS Lambda, you've probably experienced this.
A CloudWatch alarm fires.
Your phone buzzes.
You open the AWS Console.
Navigate to CloudWatch.
Open the alarm.
Find the related Lambda.
Open CloudWatch Logs.
Search through hundreds of log entries.
Ignore dozens of AWS runtime messages.
Locate the actual application error.
Figure out what happened.
Then summarize it for your teammates.
By the time you've finished, you've spent several minutes doing work that is almost identical every single time.
I realized that the investigation itself was becoming the annoying task, not fixing the problem.
So for this weekend challenge, I built OpsPilot, an AI-powered AWS application that automatically investigates CloudWatch alarms, extracts the relevant logs, understands what happened using Amazon Bedrock, and generates an incident report without requiring any manual investigation.
Instead of reading logs, I read the AI summary.



Vision

The goal was simple.
Turn manual incident investigation into a one-click—or rather, zero-click—experience.
Whenever an application fails:
  • CloudWatch detects the failure.
  • EventBridge automatically triggers OpsPilot.
  • OpsPilot gathers the logs.
  • It filters out AWS noise.
  • Builds a structured timeline.
  • Uses Amazon Bedrock to understand the incident.
  • Generates a professional investigation report.
  • Sends the report via email.
No dashboards.
No searching through logs.
No copy-pasting errors.
Everything happens automatically.



What the App Does

The demo application intentionally simulates production failures.
Examples include:
  • Database connection timeout
  • Permission denied
  • Lambda timeout
  • Memory exhaustion
Whenever one of these failures occurs:
  1. Lambda throws a real exception.
  1. CloudWatch records the logs.
  1. Lambda Errors metric increases.
  1. CloudWatch Alarm changes to ALARM.
  1. EventBridge triggers OpsPilot.
  1. OpsPilot investigates the incident.
  1. Amazon Bedrock explains the failure.
  1. Amazon SES emails the report.
The entire workflow is completely event-driven.



How I Built It

I wanted the project to feel as close to a production system as possible.
Instead of creating fake log files or manually triggering workflows, I relied entirely on AWS services.
The fake application runs every minute using Amazon EventBridge Scheduler.
Depending on the configured scenario, it either succeeds or intentionally throws an exception.
Because the Lambda genuinely fails, AWS automatically produces:
  • CloudWatch Logs
  • Lambda Error metrics
  • CloudWatch Alarm state changes
That means the investigation begins exactly the same way it would inside a real production environment.



Building the Investigation Engine

Simply forwarding raw logs to an LLM doesn't produce great results.
CloudWatch Logs contain lots of information that isn't useful:
  • START RequestId
  • END RequestId
  • REPORT lines
  • Runtime metadata
So I built two processing layers.

Incident Context Builder

This component:
  • Removes AWS runtime messages
  • Separates INFO and ERROR logs
  • Counts failures
  • Detects duplicate events
  • Produces structured JSON
Instead of hundreds of log lines, the AI receives only the important information.



Timeline Engine

The Timeline Engine makes the investigation even smarter.
It:
  • Groups logs by Request ID
  • Finds the latest failed invocation
  • Removes duplicate log entries
  • Detects the failure scenario
  • Calculates incident severity
  • Produces a chronological timeline
The AI now receives clean, structured context instead of noisy logs.



Using Amazon Bedrock

Once the incident context is prepared, OpsPilot sends it to Amazon Bedrock for analysis.
The AI reviews:
  • Timeline
  • Errors
  • Statistics
  • Alarm details
It then generates:
  • Executive summary
  • Probable root cause
  • Confidence score
  • Severity
  • Recommended actions
Instead of simply saying:
Database timeout
The report explains why it probably happened and suggests the next troubleshooting steps.



Email Notification

Finally, the investigation report is emailed automatically using Amazon SES.
The email contains:
  • Executive summary
  • Root cause analysis
  • Timeline
  • Recommendations
  • Severity
  • Confidence score
Instead of forwarding log files to teammates, they receive a readable incident report within seconds.


AWS Architecture




EventBridge Scheduler
│
▼
Fake Application (AWS Lambda)
│
▼
CloudWatch Logs
│
▼
Lambda Errors Metric
│
▼
CloudWatch Alarm
│
▼
Amazon EventBridge
│
▼
OpsPilot Investigation Lambda
│
├──────────────► CloudWatch Logs
│
├──────────────► Timeline Engine
│
├──────────────► Context Builder
│
├──────────────► Amazon Bedrock
│
▼
Amazon SES
│
▼
Incident Report Email



AWS Services Used

The project uses several AWS services working together in a fully serverless architecture.
Service
Purpose
Amazon Lambda
Fake application and investigation engine
Amazon EventBridge Scheduler
Generates recurring application activity
Amazon CloudWatch Logs
Stores application logs
Amazon CloudWatch Alarms
Detects failures
Amazon EventBridge
Triggers investigations automatically
Amazon Bedrock
AI-powered root cause analysis
Amazon SES
Sends investigation reports



Challenges I Faced

One of the biggest challenges was deciding what information should be sent to the AI.
Initially, I forwarded raw CloudWatch logs directly to Amazon Bedrock.
The results were inconsistent because the logs contained runtime metadata, duplicate entries, and AWS-generated messages that had nothing to do with the actual failure.
Building the Context Builder and Timeline Engine significantly improved the quality of the AI responses.
Another interesting challenge was understanding the newer Amazon Bedrock model invocation flow using inference profiles, which was a great learning experience.



What I Learned

This project taught me much more than simply calling an AI model.
I learned how multiple AWS services can work together to build an event-driven automation pipeline.
More importantly, I learned that AI is most effective when the input is carefully prepared.
The quality of the AI response depends heavily on the quality of the context you provide.
By cleaning and structuring CloudWatch Logs before sending them to Amazon Bedrock, the investigation became significantly more accurate and useful.



Future Improvements

This is just the beginning.
Some features I'd love to add next include:
  • Slack and Microsoft Teams notifications
  • Multi-application monitoring
  • Historical incident dashboard
  • Trend detection across recurring failures
  • Automatic Jira ticket creation
  • Amazon Q Developer integration for suggested code fixes
  • Cost optimization recommendations for AWS workloads



Conclusion

This weekend challenge was about automating one annoying task.
For me, that task was manual incident investigation.
Instead of opening multiple AWS consoles, filtering logs, and writing summaries by hand, OpsPilot now performs the investigation automatically and delivers an AI-generated report within seconds.
What started as a weekend experiment turned into a practical serverless workflow that saves time, reduces repetitive work, and lets engineers focus on solving problems rather than searching for them.


Results:



Resources Screenshots:







CloudWatch automatically detects the application failure and triggers the incident investigation workflow.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article