Skip to content

Commit 076692f

Browse files
authored
Merge pull request #16 from formula-code/grafana-dashboard-and-filter-improvements
Add Grafana dashboard, monitoring docs, and loosen symbolic filter
2 parents b2cd5f8 + c2d5d5a commit 076692f

15 files changed

Lines changed: 1891 additions & 70 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ scratch/artifacts/
200200
supabase/.temp/
201201
supabase/.branches/
202202

203+
# Grafana
204+
grafana/data/
205+
203206
# MkDocs build output
204207
site/
205208

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@ docker-clean: ## Clean up dangling Docker images and containers
3636
@echo "Cleaning up dangling Docker images and containers"
3737
@docker system prune -f
3838

39+
.PHONY: supabase-up
40+
supabase-up: ## Start local Supabase instance
41+
@npx supabase start
42+
43+
.PHONY: supabase-down
44+
supabase-down: ## Stop local Supabase instance
45+
@npx supabase stop
46+
47+
.PHONY: supabase-status
48+
supabase-status: ## Show Supabase service status and URLs
49+
@npx supabase status
50+
51+
.PHONY: grafana-migrate
52+
grafana-migrate: ## Apply the grafana_ro read-only database role
53+
@docker exec supabase_db_datasmith_new psql -U postgres -d postgres -f /dev/stdin < supabase/migrations/00009_grafana_readonly.sql
54+
@echo "grafana_ro role created"
55+
56+
.PHONY: grafana-up
57+
grafana-up: ## Start Grafana dashboard (http://localhost:3001)
58+
@docker compose -f grafana/docker-compose.yml up -d
59+
@echo "Grafana is running at http://localhost:3001"
60+
61+
.PHONY: grafana-down
62+
grafana-down: ## Stop Grafana dashboard
63+
@docker compose -f grafana/docker-compose.yml down
64+
65+
.PHONY: grafana-logs
66+
grafana-logs: ## Tail Grafana container logs
67+
@docker compose -f grafana/docker-compose.yml logs -f
68+
3969

4070
.PHONY: help
4171
help:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<a href="https://formula-code.github.io/datasmith/">
1717
<img src="https://img.shields.io/badge/%F0%9F%93%9A%20Docs-4B0082?style=for-the-badge" alt="fc-data Documentation">
1818
</a>
19+
<a href="https://nonconstricting-zara-unhinderingly.ngrok-free.dev/">
20+
<img src="https://img.shields.io/badge/%F0%9F%93%8A%20Dashboard-FF6600?style=for-the-badge" alt="Live Dashboard">
21+
</a>
1922
</p>
2023

2124
[FormulaCode](https://formula-code.github.io/) is a *continually updating* benchmark for evaluating the holistic ability of LLM agents to optimize codebases. FormulaCode consists of two parts: a [pipeline](https://github.com/formula-code/datasmith) to construct performance optimization tasks, and an [execution harness](https://github.com/formula-code/terminal-bench) that connects a language model to our terminal sandbox. _This repository contains the task generation pipeline._

docs/guide/monitoring.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
```

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![banner](https://github.com/formula-code/datasmith/raw/main/static/formula-code-datasmith.png)
22

3-
<p align="center">
3+
I<p align="center">
44
<a href="https://formula-code.github.io/">
55
<img src="https://img.shields.io/badge/%F0%9F%8C%90%20Website-0A7A5E?style=for-the-badge" alt="FormulaCode Website">
66
</a>

grafana/docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
services:
2+
grafana:
3+
image: grafana/grafana-oss:11.6.0
4+
container_name: datasmith_grafana
5+
restart: unless-stopped
6+
ports:
7+
- "3001:3000"
8+
env_file:
9+
- ../tokens.env
10+
environment:
11+
# Anonymous read-only access (no login required)
12+
- GF_AUTH_ANONYMOUS_ENABLED=true
13+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
14+
# Admin account for dashboard editing — password from tokens.env
15+
- GF_SECURITY_ADMIN_USER=admin
16+
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
17+
# Home dashboard
18+
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_UID=datasmith-overview
19+
# Minimum refresh interval
20+
- GF_DASHBOARDS_MIN_REFRESH_INTERVAL=1m
21+
# Plugins
22+
- GF_INSTALL_PLUGINS=netsage-sankey-panel,marcusolsson-treemap-panel
23+
volumes:
24+
- grafana-data:/var/lib/grafana
25+
- ./provisioning/datasources:/etc/grafana/provisioning/datasources:ro
26+
- ./provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
27+
- ./provisioning/dashboards-json:/var/lib/grafana/dashboards:ro
28+
networks:
29+
- supabase_net
30+
31+
volumes:
32+
grafana-data:
33+
34+
networks:
35+
supabase_net:
36+
external: true
37+
name: supabase_network_datasmith_new

0 commit comments

Comments
 (0)