Autonomous SRE Agent β LangGraph β’ RAG β’ Local LLM β’ PagerDuty β’ Human-in-the-Loop
Every engineering team has that one senior SRE β the person who has lived through every production incident, built the runbooks, and knows exactly what to do when things break.
Then they leave.
The new engineer joins on Monday. A critical production incident fires on Tuesday. They have access to the systems but not the institutional knowledge. Every minute of confusion costs the business.
AutoInvestigatorOps solves this.
It's an autonomous SRE agent that:
- Intercepts production incidents the moment they fire
- Searches historical runbooks to find what matches
- Uses AI to perform root cause analysis
- Generates a remediation script
- Waits for human approval before executing anything
The experienced engineer's knowledge β codified, searchable, always available.
PagerDuty / Datadog Webhook
β
FastAPI Webhook Server
(async, non-blocking β returns 202
immediately to prevent retry storms)
β
LangGraph State Machine
βββββββββββββββββββββββββββββββ
β Node 1: Triage Alert β
β Node 2: Gather Telemetry β
β Node 3: Search Runbooks β
β Node 4: Synthesize RCA β
β Node 5: Execute Remediationβ
βββββββββββββββββββββββββββββββ
β
ChromaDB Vector Store
(semantic search over runbooks)
β
Local LLM (LFM-2B via LM Studio)
(root cause analysis β no data
leaves your network)
β
Human Approval Gate β critical
β
PowerShell Remediation Execution
β
Prometheus + Grafana
(full observability)
All incident data stays within your network. No cloud API calls for sensitive operational data. LFM-2B runs entirely on local hardware via LM Studio.
ChromaDB stores engineering runbooks as vector embeddings. When an incident fires, semantic search finds the most relevant runbook β even if the incident description is worded differently from the runbook title.
AI generates the remediation script. A human approves it before it runs. This protects against:
- Prompt injection attacks via malicious log entries
- AI errors affecting production dependencies
- Unintended consequences of automated execution
PagerDuty expects a webhook response within 5 seconds or it retries β creating duplicate investigations. FastAPI BackgroundTasks returns 202 Accepted immediately while the investigation runs asynchronously.
Prometheus metrics track:
sre_incidents_received_totalβ incidents by urgency and servicesre_investigation_duration_secondsβ full investigation timesre_llm_inference_duration_secondsβ LLM response latencysre_remediation_outcomes_totalβ success/failed/skippedsre_active_investigationsβ concurrent investigations
All visualised in Grafana dashboards.
| Component | Technology | Purpose |
|---|---|---|
| API Layer | FastAPI + Pydantic | Async webhook ingestion |
| Orchestration | LangGraph | 5-node state machine |
| Vector Search | ChromaDB | Runbook RAG retrieval |
| Embeddings | HuggingFace MiniLM-L6-v2 | Semantic search |
| Local LLM | LFM-2B via LM Studio | Root cause analysis |
| Remediation | PowerShell subprocess | Safe script execution |
| Metrics | Prometheus + Grafana | Production observability |
| Schema | TypedDict | Typed state management |
- Python 3.11+
- LM Studio β for local LLM inference
- Prometheus + Grafana (optional, for observability)
git clone https://github.com/Tejas163/AutoInvestigatorOps.git
cd AutoInvestigatorOps
# Create virtual environment
python -m venv .venv
# Activate (Windows)
.\.venv\Scripts\Activate.ps1
# Activate (Linux/Mac)
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtcp .env.example .envEdit .env:
SRE_AGENT_LLM_URL=http://localhost:1234/v1
SRE_AGENT_LLM_KEY=your-lm-studio-key- Open LM Studio
- Load the LFM-2B model
- Start the local server on port 1234
python investigator.pyServer starts at http://localhost:8000
curl -X POST http://localhost:8000/webhooks/pagerduty \
-H "Content-Type: application/json" \
-d @payload.jsondocker-compose -f docker-compose-monitoring.yml up- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
- Metrics endpoint: http://localhost:8000/metrics
Prometheus:
- Download from prometheus.io/download
- Extract and run:
prometheus.exe --config.file=prometheus.yml
Grafana:
- Download installer from grafana.com/grafana/download
- Run installer β starts as Windows service automatically
- Open http://localhost:3000
1. Incident Fires
PagerDuty detects a production anomaly and sends a webhook to /webhooks/pagerduty
2. Async Dispatch
FastAPI validates the payload and immediately returns 202 Accepted. The investigation runs in a background task β PagerDuty doesn't time out.
3. Triage LangGraph enters the first node β extracting incident metadata: service name, urgency, incident ID, timestamp.
4. Telemetry Gathering
The agent scans production_logs.txt for log entries matching the affected service. It detects metric anomalies β like connection pool exhaustion β from log patterns.
5. Runbook Retrieval ChromaDB performs semantic similarity search over stored runbooks. The most relevant runbook is retrieved based on incident description β not just keyword matching.
6. Root Cause Analysis The local LLM receives three inputs:
- Relevant production logs
- Detected metric anomalies
- Retrieved runbook content
It synthesises a structured JSON response:
{
"root_cause": "Redis connection pool exhausted",
"confidence_score": 0.95,
"recommended_action": "Flush connection pools",
"target_script": "Write-Output 'Flushing...'"
}7. Human Approval Gate
The remediation script is NOT executed automatically. The remediation_approved flag must be set to True by a human operator before execution proceeds.
8. Remediation Execution Once approved, the generated PowerShell script is written to disk and executed via subprocess. Output is captured and logged.
9. Metrics Updated Prometheus counters and histograms are updated with investigation duration, LLM latency, and remediation outcome.
Production incident data contains sensitive infrastructure details β server names, database connection strings, error messages with internal paths. Sending this to a cloud API creates data exfiltration risk. Local inference keeps all data within the enterprise boundary.
- Prompt injection protection: A malicious log entry could attempt to trick the LLM into generating a destructive script. Human review catches this.
- Dependency awareness: The LLM doesn't know which files and folders other applications depend on. A human does.
- Audit compliance: Every remediation action requires human sign-off β creating an audit trail for compliance.
PagerDuty retries webhooks that don't respond within 5 seconds. A synchronous investigation (15-30 seconds) would trigger duplicate alerts. Background tasks solve this without message queues.
AutoInvestigatorOps/
βββ investigator.py # FastAPI webhook server + Prometheus metrics
βββ pipeline.py # LangGraph 5-node state machine
βββ schemas.py # TypedDict state schema
βββ requirements.txt # Python dependencies
βββ prometheus.yml # Prometheus scrape config
βββ docker-compose-monitoring.yml # Prometheus + Grafana stack
βββ Dockerfile # Container definition
βββ .env.example # Environment variable template
βββ payload.json # Sample PagerDuty webhook payload
βββ runbooks/
βββ redis_runbook.md # Sample Redis incident runbook
class InvestigationState(TypedDict):
incident_id: str
service_name: str
relevant_logs: List[str]
metric_anomalies: List[Dict]
historical_matches: List[Dict]
root_cause_summary: Dict
remediation_approved: bool # Human sets this
remediation_executed: bool
remediation_logs: str
investigation_steps_taken: List[str]
next_step: str- Multi-agent architecture β parallel log analysis and runbook retrieval agents
- Langfuse LLM observability integration
- RAGAS evaluation for RAG pipeline quality
- Input guardrails for prompt injection protection
- pytest test suite
- GitHub Actions CI/CD pipeline
- Cloud deployment (AWS/GCP)
- Slack/Teams notification integration
- Support for Datadog, OpsGenie webhooks
Tejaswi S K β AI Engineer | AIOps | LangGraph | Enterprise IT Operations
- π GitHub: github.com/Tejas163
- π€ HuggingFace: huggingface.co/Tejas86 β Fine-tuned RPA & DevOps SLM (100+ downloads)
- π§ tejaskrshna@gmail.com
MIT License β see LICENSE for details.
Built on 10 years of enterprise IT operations experience β solving the problems I've watched teams struggle with firsthand.