About the Project

Description

The EC2-monitor-agent is an intelligent assistant designed to simplify AWS EC2 instance monitoring and management. It leverages AWS CloudWatch metrics to provide real-time insights into CPU utilization, system health, and other key performance indicators. The agent can list instances, fetch detailed metrics, and visualize data through intuitive plots, transforming complex cloud data into actionable intelligence.

What Inspired Us?

We recognized that while AWS provides powerful monitoring tools, they can often be overwhelming for developers and small teams who need quick, focused insights. Our goal was to bridge this gap by creating a lightweight, multi-interface agent that delivers essential monitoring data directly to users via their preferred medium—be it the command line, a Streamlit dashboard, or a Gradio UI.

Architecture & How We Built It

The system is built on a modular architecture that separates concerns for clarity and scalability:

graph TD
    A[User Interface] --> B{Backend Model};

    subgraph UI [User Interface Layer]
        A1[Streamlit/Gradio/CLI]
    end

    subgraph Backend [Backend & Data Layer]
        B --> C[AWS CloudWatch];
        B --> D[Strands Agent];
        B --> E[cloudwatch_metrics_tool];
        B --> F[Matplotlib for Plotting];
        B --> G[aws_agent_history.json];
        B --> H[use_aws];
    end

    subgraph Cloud [AWS Infrastructure]
        C --> I[AWS EC2];
        H --> I;
        I --> J[Other AWS Services];
    end

    F --> A1;
    G --> B;

Key Components:

  1. Multi-Interface Frontend: Users can interact through:

    • CLI (aws_agent_cli.py): For quick terminal-based checks and automation
    • Streamlit (aws_agent_app.py): For a rich, interactive web dashboard
    • Gradio (aws_agent_gradio.py): For a simple, deployable web interface
  2. Intelligent Backend Model: The core logic handles:

    • Authentication and session management with AWS via boto3
    • Orchestrating data flow between various components
    • Processing user commands from different interfaces
  3. Data Collection & Processing:

    • AWS CloudWatch Integration: Fetches metrics like CPUUtilization using the cloudwatch_metrics_tool.
    • System Agent: The "Strands Agent" collects instance-level system data.
    • Persistence: Historical data and agent state are managed in aws_agent_history.json.
  4. Visualization Engine: Uses Matplotlib to generate clear, static plots of metric trends over time, making it easy to spot performance bottlenecks.

Technical Implementation

The project is built with Python, leveraging its extensive ecosystem for data science and cloud operations. Dependency management and execution are streamlined using the modern uv toolchain.

# Example: Installing and running the agent
git clone https://github.com/AdityaWorkmates/EC2-monitor-agent.git
cd EC2-monitor-agent

# Run the CLI version
uv run aws_agent_cli.py

# Or launch the web interfaces
uv run streamlit run aws_agent_app.py
uv run gradio aws_agent_gradio.py

Challenges We Faced

  • Multi-Interface Synchronization: Ensuring a consistent user experience and data output across three different UI paradigms required careful abstraction of the core business logic.
  • AWS Authentication & Security: Configuring the minimal necessary IAM permissions for the agent to function securely was a meticulous process, adhering to the principle of least privilege.
  • Data Persistence Design: Structuring the aws_agent_history.json file to efficiently store and retrieve historical data without a full-fledged database was a key architectural decision.
  • Dependency Management: Using uv and pyproject.toml ensured reproducible environments, but required learning this modern tooling ecosystem.

What We Learned

This project provided hands-on experience with:

  • Full-stack development in Python, from CLI tools to web UIs
  • Advanced AWS SDK (boto3) usage and CloudWatch metrics retrieval
  • Building multi-interface applications with shared backend logic
  • Modern Python packaging and dependency management with uv
  • Data visualization principles with Matplotlib
  • Designing secure cloud-native applications

Built With

  • agents
  • amazon-web-services
  • argparse
  • aws-ec2-&-cloudwatch
  • bedrock
  • boto3
  • cloudwatch
  • custom-agents
  • ec2
  • iam
  • matplotlib
  • metrics
  • psutil
  • python
  • slack-webhooks
  • strand
Share this project:

Updates