Skip to content

About

AI support copilot for a mini data platform: Airflow+PySpark+Trino, Prometheus/Grafana, PagerDuty-style incidents, custom MCP server and a Slack agent that triages failures.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PlatformPulse β€” AI support copilot for a data platform

Break a data platform on purpose. Watch an AI agent detect, triage and explain it in Slack.
Airflow + PySpark + Trino Β· Prometheus / Alertmanager / Grafana Β· PagerDuty-style incidents Β· custom MCP server Β· Slack Bolt Β· β‚Ή0 to run

Python Airflow Spark Trino Prometheus Grafana FastAPI MCP Slack Docker License: MIT

Results Β· Quick start Β· Architecture Β· MCP server Β· Deep dive Β· Built with Claude Code Β· Try it in Codespaces


πŸ’‘ Why

On a data platform, the support loop is always the same. A job breaks, an alert fires, and someone digs through metrics, task logs and runbooks, then posts an update in Slack and chases the incident to resolution. PlatformPulse rebuilds that loop at laptop scale and hands the digging to an agent.

You run a small data platform, break it in one of four realistic ways, and watch it work:

  1. πŸ”₯ Detect. Airflow metrics flow through StatsD into Prometheus, and an alert rule fires.
  2. 🚨 Open. Alertmanager sends a webhook to a PagerDuty-style incident service (open β†’ ack β†’ resolve).
  3. πŸ€– Triage. An LLM agent calls its own MCP server to read DAG state, task logs, metrics and runbooks, then classifies the failure.
  4. πŸ’¬ Explain. The diagnosis lands in the incident's Slack thread with evidence, a next step and the matching runbook.
  5. πŸ“Š Measure. Grafana shows platform health, MTTA/MTTR and how often the agent resolved things without a human.

Demo: chaos.py oom β†’ alert β†’ incident β†’ Slack β†’ agent triage, with Grafana updating live
A real, unedited run: chaos.py oom β†’ alert at t+80s β†’ posted to Slack β†’ agent classifies oom in 24s, with Grafana updating live.
Frames were captured automatically from the running stack, and the thread text is the agent's actual output.

πŸ“‘ Table of contents

πŸ“ˆ Results

Measured, not estimated. pulse/eval.py runs the full loop for every case: inject the failure β†’ the alert fires β†’ an incident opens β†’ the agent triages it. Raw rows: eval/results.csv.

Failure type Model Runs Accuracy Median detect Median time-to-summary p90 time-to-summary
πŸ’₯ OOM gpt-oss-120b 4 100% 28.4 s 27.5 s 34.7 s
🧩 Bad schema gpt-oss-120b 4 100% 26.7 s 19.4 s 30.0 s
⏱️ Timeout gpt-oss-120b 4 100% 107.8 s 8.1 s 8.5 s
🧊 Stuck DAG gpt-oss-20b 5 80% 46.1 s 57.4 s 147.7 s
All mixed 17 94% 40.6 s 19.4 s 34.7 s
How to read these numbers (and what's excluded)
  • Detect is the time from injecting the failure to the incident row. For timeout it includes the job's 90 s execution_timeout by design.
  • Time-to-summary is how long the agent takes to triage once the incident is open.
  • gpt-oss-120b's Groq free tier allows 200k tokens a day, and it ran out mid-eval. The stuck runs therefore used gpt-oss-20b, and the model is recorded on every row.
  • One stuck run crashed inside the agent and is counted as a miss.
  • Three stuck runs recorded under an eval-harness bug (the pool was restored before triage) are excluded. They're kept in eval/stuck_runs_invalid.csv, and the bug is explained in REVIEW_LOG #9.
  • Eval incidents are resolved as eval and never count toward the dashboard's deflection rate.

✨ Features

πŸ§ͺ Chaos on demand chaos.py injects a Spark OOM, a schema mismatch, a task timeout, or a stuck DAG (a 0-slot pool)
πŸ”­ Observability as code StatsD mapping, 5 Prometheus rules, an Alertmanager webhook, and a Grafana dashboard JSON, all provisioned on up
🚨 PagerDuty-style incidents FastAPI + SQLite: dedupe on fingerprint + start time, open β†’ ack β†’ resolve, resolved_by=agent|human
🧰 Custom MCP server 6 read-only tools over 4 backends: Prometheus, the Airflow REST API, the incident DB, and Trino
πŸ€– Tool-calling agent MCP stdio client + Groq, strict JSON output, retries on 429 and malformed tool calls
πŸ“š Runbook search 12 runbooks, embedded locally with fastembed (bge-small), no API cost
πŸ’¬ Slack app Alerts with buttons, an auto-triage thread, /pulse, @mention Q&A with Solved / Escalate, and an App Home tab
πŸ“Š CX metrics MTTA, MTTR, agent time-to-summary, support requests by category, and deflection rate
πŸͺΆ Laptop-sized One docker compose up, about 5.8 GB of memory caps, about 2.2 GB idle, β‚Ή0 to run

Grafana Customer Experience dashboard
The provisioned Grafana "Customer Experience" dashboard: platform health, task outcomes, pool slots, incidents, support and agent latency.

πŸ— Architecture

flowchart TB
  CH["πŸ§ͺ chaos.py<br/>oom Β· bad_schema Β· timeout Β· stuck"] -.->|breaks| AF

  subgraph Platform["πŸ—„οΈ Mini data platform"]
    direction LR
    AF["Airflow 2.10<br/>LocalExecutor"] -->|runs| SP["PySpark<br/>local mode"]
    AF --- PG[("Airflow<br/>Postgres")]
    TR["Trino 470"] -->|SQL| PG
  end

  subgraph Obs["πŸ”­ Observability"]
    direction LR
    SE["statsd-exporter"] --> PR["Prometheus<br/>5 alert rules"] --> AM["Alertmanager"]
    PR --> GF["πŸ“Š Grafana CX"]
  end

  AF -->|StatsD| SE
  AM -->|webhook| IS["🚨 Incident service<br/>FastAPI + SQLite"]
  IS -->|"/metrics: MTTA Β· MTTR Β· deflection"| PR

  subgraph Pulse["πŸ€– pulse container"]
    direction LR
    SL["Slack app<br/>Bolt Β· Socket Mode"] --> AG["Agent<br/>Groq gpt-oss"] <-->|stdio| MCP["MCP server Β· 6 read-only tools<br/>Prometheus Β· Airflow Β· incidents Β· Trino"]
  end

  IS -->|new incidents| SL
  SL <--> SK(("πŸ’¬ Slack"))
Loading
Services, ports and memory budget
Service Role Port Mem cap
airflow standalone, LocalExecutor, JDK 17 + PySpark 8080 2.5 GB
trino SQL over tpch + the Airflow metadata DB, 1 GB heap 8081 1.5 GB
postgres Airflow metadata – 256 MB
statsd-exporter StatsD β†’ Prometheus 9102 64 MB
prometheus 5 s scrapes, alert rules 9090 300 MB
alertmanager webhook to the incident service 9093 64 MB
incident incident lifecycle + /metrics 8000 128 MB
grafana provisioned dashboard 3000 256 MB
pulse Slack app + agent + MCP server + eval – 768 MB

The design decisions are written up in ARCHITECTURE.md and DESIGN.md.

πŸš€ Quick start

Option A: run it in your browser (nothing to install)

Open in GitHub Codespaces

This spins up the whole stack in your own free cloud VM (4 cores / 16 GB). The first build takes about 8–10 minutes, after which Grafana, Airflow, Prometheus and the incident API open as forwarded ports in the Ports tab.

  • When asked for secrets, add a free Groq key as GROQ_API_KEY so the agent can run. The Slack tokens are optional.
  • Free GitHub accounts get 120 core-hours a month, which is about 30 hours of this 4-core machine. Stop the codespace when you're done.
  • In the codespace terminal, run python chaos.py oom and watch the dashboard.

Option B: run it locally

You need Docker Desktop (8 GB for WSL2/VM), a free Groq API key and, optionally, a free Slack workspace.

git clone https://github.com/Vaibhav2824/PlatformPulse.git && cd PlatformPulse
cp .env.example .env            # add GROQ_API_KEY (Slack tokens optional)
docker compose up -d --build
Open URL
Grafana CX dashboard http://localhost:3000
Airflow (admin / admin, dev only) http://localhost:8080
Prometheus alerts http://localhost:9090/alerts
Incident API docs http://localhost:8000/docs
Setting up the Slack app (5 minutes)
  1. Go to api.slack.com/apps β†’ Create New App β†’ From a manifest, choose YAML, and paste slack_manifest.yml.
  2. Under Basic Information β†’ App-Level Tokens, generate a token with connections:write and put it in SLACK_APP_TOKEN (xapp-…).
  3. Under Install App, install the app to your workspace and put the bot token in SLACK_BOT_TOKEN (xoxb-…).
  4. Create a public #platform-alerts channel and run /invite @PlatformPulse.
  5. Run docker compose up -d pulse.

Socket Mode means you don't need a public URL or tunnel.

πŸ§ͺ Break it on purpose

python chaos.py oom          # Spark driver Java heap OOM              β†’ sales_daily
python chaos.py bad_schema   # renamed input columns β†’ AnalysisException β†’ events_ingest
python chaos.py timeout      # job hangs β†’ AirflowTaskTimeout          β†’ user_metrics
python chaos.py stuck        # spark_pool set to 0 slots β†’ task never starts
python chaos.py restore      # put the pool back

Within about 30 s an alert fires, an incident opens, Slack gets the alert with Ack Β· Summarize Β· Runbook Β· Resolve buttons, and the agent posts its diagnosis in the thread.

To reproduce the eval yourself (it uses a lot of Groq tokens):

docker compose run --rm --no-deps pulse python eval.py 5

🧰 The MCP server

pulse/mcp_server.py is a standard stdio MCP server built with FastMCP. Every tool is read-only.

Tool Backend What the agent uses it for
get_dag_status Airflow REST latest runs, task states, try numbers, pool slots
get_task_logs Airflow REST error lines + the log tail (the evidence)
query_prometheus Prometheus live metrics, firing alerts
get_incidents Incident service open/recent incidents
search_runbooks fastembed (local) semantic search over 12 runbooks
run_trino_query Trino β†’ Airflow DB run history via SQL (single SELECT/SHOW/DESCRIBE/EXPLAIN/WITH only, 50-row cap)

Any MCP client can use it, including Claude Desktop:

{ "mcpServers": { "platformpulse": {
    "command": "docker",
    "args": ["compose", "-f", "<repo>/docker-compose.yml", "run", "--rm", "-i", "--no-deps", "pulse", "python", "mcp_server.py"] } } }
Example triage output (a real run)
{
  "category": "timeout",
  "summary": "The user_metrics.run_spark task failed due to an AirflowTaskTimeout. The Spark job exceeded its execution_timeout and the subprocess was killed, so the run was marked FAILED.",
  "evidence": ["{timeout.py:68} ERROR - Process timed out, PID: 1360",
               "airflow.exceptions.AirflowTaskTimeout: Timeout, PID: 1360"],
  "runbook": "rb-task-timeout",
  "next_step": "Check upstream source latency; if the runtime is expected, raise execution_timeout and add retries with backoff.",
  "tools_used": ["get_dag_status", "get_task_logs", "search_runbooks"]
}

πŸ’¬ Slack experience

Surface What it does
🚨 Alert post severity, alert, DAG/task, incident # and status, with Ack · Summarize · Runbook · Resolve (agent) · Resolve (human) buttons
🧡 Auto-triage thread category, summary, evidence, next step, runbook id and agent latency
/pulse service health, task failures in the last hour, MTTA/MTTR, deflection, open incidents
@PlatformPulse … Q&A backed by live tools, with Solved βœ… / Escalate πŸ™‹ buttons that feed the deflection rate
🏠 App Home the same health view, refreshed whenever the tab is opened

πŸ—‚ Project structure

PlatformPulse/
β”œβ”€β”€ airflow/              # Dockerfile (slim + JDK17 + PySpark), 3 DAGs, Spark job with chaos hooks
β”œβ”€β”€ observability/        # statsd mapping, prometheus.yml, 5 alert rules, alertmanager.yml
β”œβ”€β”€ incident_service/     # FastAPI + SQLite incident lifecycle, /metrics, pytest suite
β”œβ”€β”€ pulse/
β”‚   β”œβ”€β”€ mcp_server.py     # 6-tool MCP server
β”‚   β”œβ”€β”€ agent.py          # Groq tool-calling loop over MCP stdio
β”‚   β”œβ”€β”€ slack_app.py      # Bolt app: alerts, buttons, /pulse, @mention, App Home
β”‚   β”œβ”€β”€ eval.py           # chaos β†’ incident β†’ triage benchmark
β”‚   └── runbooks/         # 12 markdown runbooks
β”œβ”€β”€ grafana/              # provisioning + customer_experience.json
β”œβ”€β”€ trino/                # 1 GB heap, tpch + postgresql catalogs
β”œβ”€β”€ notebooks/            # postmortem analysis of eval + incidents
β”œβ”€β”€ eval/                 # results.csv, results.md
β”œβ”€β”€ chaos.py              # stdlib-only failure injector
└── docker-compose.yml

πŸ€– Built with Claude Code

PlatformPulse was built in one 5-hour sprint with Claude Code as the pair programmer. I owned the scope, the design calls and the verification. Claude Code wrote most of the code, and nothing was accepted until it had run against the real stack.

How the work was split

Step Claude Code Me
Plan turned the brief into a phase-gated plan, then the PRD, ARCHITECTURE and DESIGN before any code set scope (full spec in 5 h), LLM provider, hosting, folder
Build wrote the compose stack, DAGs, chaos, alert rules, incident service, MCP server, agent and Slack app created the Slack app and Groq key, approved each phase gate
Verify ran every phase live: injected each failure, checked the log signature, the alert, the incident row and the agent verdict checked the Slack flow by hand (alert, thread, Ack, /pulse, @mention)
Measure wrote and ran the eval, and fixed the harness when it was wrong decided how to handle the quota limit (switch models, label every row)

Critical review, not autopilot. Every time Claude Code's output was wrong, the fix and the reason went into REVIEW_LOG.md. There are 13 entries, and most of them only showed up when the real stack ran, never in code review:

# What looked fine What running it revealed
5 a "stuck pool" alert on airflow_pool_starving_tasks it stays 0 for a truly stuck pool, and fired on normal contention
7 the default LLM llama-3.3-70b-versatile 404 model_not_found: the provider had retired it
9 the eval harness it restored the pool before the agent triaged, so it was measuring a healed system
10 resolving eval incidents as agent it inflated dashboard "deflection" to 95%, so test traffic was polluting KPIs
11 dashboard JSON edited via PowerShell a hidden UTF-8 BOM, so Grafana silently kept the old dashboard
13 a "first failure" alert rule on a fresh stack it opened 3 false incidents that never showed locally

Other design choices: the agent is read-only by design (it recommends and humans remediate), every image and package version is pinned, and the incident service has a pytest suite (docker compose run --rm incident pytest).

πŸ“š Docs

Doc What's in it
PRD.md problem, users, goals, success metrics, JD-gap mapping
ARCHITECTURE.md components, data flow, memory budget, design rationale
DESIGN.md metrics, alert rules, DB schema, API, MCP contracts, Slack UX
REVIEW_LOG.md every correction made to Claude Code's output, with the reason
notebooks/postmortem.ipynb postmortem analysis

Built by @Vaibhav2824 Β· MIT License Β· ↑ back to top

About

AI support copilot for a mini data platform: Airflow+PySpark+Trino, Prometheus/Grafana, PagerDuty-style incidents, custom MCP server and a Slack agent that triages failures.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages