|
| 1 | +# Monitoring with Grafana |
| 2 | + |
| 3 | +fc-data includes a pre-configured Grafana dashboard for monitoring the pipeline, browsing data, and tracking dataset growth. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Local Supabase instance running (`make supabase-up`) |
| 8 | +- Docker available on the host |
| 9 | + |
| 10 | +## Quick Start |
| 11 | + |
| 12 | +```bash |
| 13 | +# Apply the read-only database role (first time only) |
| 14 | +make grafana-migrate |
| 15 | + |
| 16 | +# Start Grafana |
| 17 | +make grafana-up |
| 18 | +``` |
| 19 | + |
| 20 | +Grafana is now available at **<http://localhost:3001>** with no login required (anonymous read-only access). |
| 21 | + |
| 22 | +To expose it publicly via ngrok: |
| 23 | + |
| 24 | +```bash |
| 25 | +ngrok http 3001 |
| 26 | +``` |
| 27 | + |
| 28 | +## Architecture |
| 29 | + |
| 30 | +Grafana runs as a Docker container that joins the existing Supabase Docker network. It connects to Postgres via a **read-only** `grafana_ro` database role that can only `SELECT` — no writes are possible, even from the Explore SQL editor. |
| 31 | + |
| 32 | +``` |
| 33 | +┌──────────────┐ ┌──────────────────────────┐ |
| 34 | +│ Browser │────▶│ Grafana (port 3001) │ |
| 35 | +└──────────────┘ │ Anonymous Viewer access │ |
| 36 | + └───────────┬──────────────┘ |
| 37 | + │ SELECT only |
| 38 | + ┌───────────▼──────────────┐ |
| 39 | + │ Supabase PostgreSQL │ |
| 40 | + │ (grafana_ro role) │ |
| 41 | + └──────────────────────────┘ |
| 42 | +``` |
| 43 | + |
| 44 | +## Dashboard Panels |
| 45 | + |
| 46 | +The provisioned dashboard ("DataSmith Pipeline Overview") includes: |
| 47 | + |
| 48 | +| Section | Panels | |
| 49 | +|---------|--------| |
| 50 | +| **Dataset Growth** | Containers built by month, stat counts (PRs, containers, packages, repos), PR-to-container rate | |
| 51 | +| **Repository Overview** | All repos by stars, containers-by-repo treemap | |
| 52 | +| **Pull Request Insights** | Performance commit ratio, dataset time span, difficulty distribution, PR volume over time, optimization type distribution | |
| 53 | +| **Package Resolution** | Python version distribution, installability by repo, resolution strategy breakdown | |
| 54 | +| **Pipeline Status** | Active runners table, completion gauge, recent failures | |
| 55 | +| **Synthesis** | Success rate over time, failure stage distribution, top error messages | |
| 56 | +| **Synthesis Deeper Analysis** | First-attempt vs retry success, hardest repos, agent head-to-head | |
| 57 | +| **Attempt Details** | Attempts per repo, duration by agent, duration over time | |
| 58 | +| **Resource Metrics** | Build metrics table, image size vs build time, avg resources over time | |
| 59 | +| **Pipeline Funnel** | End-to-end conversion: Repos → PRs → Perf PRs → Resolved → Built → Published | |
| 60 | +| **Data Explorer** | Filtered table of performance PRs with referenced issues | |
| 61 | + |
| 62 | +## Ad-hoc SQL Queries |
| 63 | + |
| 64 | +Use Grafana's **Explore** mode (compass icon in the sidebar) to run arbitrary read-only SQL against the database. The `grafana_ro` role has `SELECT` access to all tables. |
| 65 | + |
| 66 | +## Admin Access |
| 67 | + |
| 68 | +To edit dashboards in the Grafana UI, log in with: |
| 69 | + |
| 70 | +- **Username:** `admin` |
| 71 | +- **Password:** value of `GRAFANA_ADMIN_PASSWORD` in `tokens.env` (defaults to `admin`) |
| 72 | + |
| 73 | +## Configuration Files |
| 74 | + |
| 75 | +| File | Purpose | |
| 76 | +|------|---------| |
| 77 | +| `grafana/docker-compose.yml` | Grafana service definition | |
| 78 | +| `grafana/provisioning/datasources/supabase-postgres.yml` | PostgreSQL datasource (read-only) | |
| 79 | +| `grafana/provisioning/dashboards/dashboard-provider.yml` | Dashboard file provider config | |
| 80 | +| `grafana/provisioning/dashboards-json/datasmith-overview.json` | Dashboard panels and queries | |
| 81 | +| `supabase/migrations/00009_grafana_readonly.sql` | Read-only Postgres role | |
| 82 | + |
| 83 | +## Makefile Targets |
| 84 | + |
| 85 | +```bash |
| 86 | +make grafana-up # Start Grafana |
| 87 | +make grafana-down # Stop Grafana |
| 88 | +make grafana-logs # Tail container logs |
| 89 | +make grafana-migrate # Apply the grafana_ro database role |
| 90 | +``` |
0 commit comments