Loading...
Loading...
Audit every endpoint in a PostHog project for staleness, failed materialisations, and unused materialised versions. Use when the user asks "what endpoints can I clean up?", "are any of my endpoints broken?", "which materialised versions are still being called?", or wants a one-shot cleanup pass over the Endpoints product. Produces a prioritised report grouped by issue type, with recommended actions but does not modify anything without explicit confirmation.
npx skill4agent add posthog/skills auditing-endpointsdiagnosing-endpoint-performancequery_logexecute-sqlendpoint-versionslast_executed_at| Tool | What it's for |
|---|---|
| Primary read path. Query |
| Per endpoint: is materialisation eligible, current status, last run, last error (not in the system tables — use this tool) |
| All versions for one endpoint, latest first, with each version's query, materialisation state, and |
| Write path — disable ( |
| Tell the PostHog team what's missing or confusing in this flow so the product and skill improve |
endpoints-get-allendpoint-getquery_log| Category | Trigger | Typical action |
|---|---|---|
| Never called | No rows in | Confirm with the user, then disable |
| Stale | | Confirm with the user; often safe to disable |
| Inactive | | Verify intent; if abandoned, delete |
| Failing materialisation | | Hand off to |
| Unused materialised version | A materialised version whose | Unmaterialise that version, or roll to a newer one |
| Drifted versions | Many versions exist (query changed repeatedly) | History noise — not an issue, but worth noting |
last_executed_atexecute-sqlsystem.data_modeling_endpointsSELECT name, is_active, current_version, derived_from_insight, last_executed_at
FROM system.data_modeling_endpoints
ORDER BY namelast_executed_atquery_logquery_logquery_logSELECT name, count() AS calls, max(query_start_time) AS last_called
FROM query_log
WHERE endpoint LIKE '%/endpoints/%' AND is_personal_api_key_request
GROUP BY name
ORDER BY namequery_logquery_logquery_duration_msread_rowsread_bytesendpoint-versionsendpoint-materialization-statusstatus: "Failed"endpoint-versionslast_executed_at## Endpoints audit — 9 issues
### 🔴 Failing materialisations (1)
- weekly_revenue (v3) — Failed 2h ago, "Column 'event_date' does not exist"
→ hand off to diagnosing-endpoint-performance
### 🟠 Never called via API key (3)
- internal_admin_query — created 5 months ago
- legacy_signup_funnel — created 1 year ago, materialised
- experiment_arm_lookup — created 9 months ago
### 🟠 Unused materialised versions (2) [from endpoint-versions]
- monthly_active_users — v3 materialised, last_executed_at null (currently on v4 — unmaterialise v3)
- order_summary — v1 materialised, last_executed_at null
### 🟡 Stale (3)
- holiday_promo_2024 — last called 4 months ago
- ab_test_phase_1 — last called 2 months ago
- daily_revenue_cohort — last called 45 days ago
Recommended order:
1. Investigate the failing materialisation (blocks fresh data)
2. Unmaterialise the unused versions (free storage + compute)
3. Disable the never-called endpoints (if user confirms)
4. Review stale endpoints with the userendpoint-updateis_materialized: falseendpoint-updateis_active: falsediagnosing-endpoint-performanceUser: "Audit my endpoints"
Agent steps:
- execute-sql on system.data_modeling_endpoints → 12 endpoints (4 materialised)
- execute-sql on query_log grouped by name → 8 endpoints have calls
- endpoint-materialization-status on each materialised endpoint → 1 failing
- endpoint-versions on the materialised ones → order_summary v2's last_executed_at is null
- Report:
"Found 6 things worth looking at across 12 endpoints:
🔴 Failing materialisations (1)
- monthly_active_users (v2) — materialisation failed yesterday with
'memory limit exceeded'. The endpoint is still callable inline but
responses will be slower.
🟠 Never called via API key (3)
- legacy_funnel_v1 — created 11 months ago
- test_export — created 3 months ago
- admin_dump — created 8 months ago, materialised (wasteful)
🟠 Unused materialised versions (1) [from endpoint-versions]
- order_summary v2 — materialised but its last_executed_at is null
while v3 is current. Likely safe to unmaterialise v2.
🟡 Stale (1)
- holiday_2024 — last called 5 months ago
Caveat: usage only counts personal-API-key calls; playground and
dashboard runs aren't counted. Per-version recency comes from
endpoint-versions and is sparse. Confirm before disabling.
Want me to start with the failing materialisation, or clean up the
unused version first?"system.data_modeling_endpointsquery_logexecute-sqlendpoint-versionslast_executed_atendpoint-updateis_materialized: falseis_active: false