| name | posthog-observability |
| description | Monitor PostHog integration health: event ingestion rates, feature flag
evaluation latency, billing volume tracking, and Prometheus/Grafana alerting.
Trigger: "posthog monitoring", "posthog metrics", "posthog observability",
"monitor posthog", "posthog alerts", "posthog dashboard".
|
| allowed-tools | Read, Write, Edit |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","posthog","monitoring","observability","dashboard"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
PostHog Observability
Overview
Monitor PostHog integration health with four key signals: event ingestion rate (are events flowing?), feature flag evaluation latency (are flags fast enough for hot paths?), event volume by type (detect instrumentation regressions), and API rate limit consumption (are we approaching 429s?).
Prerequisites
- PostHog project with personal API key (
phx_...)
- Application instrumented with PostHog SDK
- Prometheus/Grafana or equivalent monitoring stack (optional)
Instructions
Step 1: Event Ingestion Health Check
set -euo pipefail
curl "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID/query/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": {
"kind": "HogQLQuery",
"query": "SELECT toStartOfHour(timestamp) AS hour, count() AS events FROM events WHERE timestamp > now() - interval 24 hour GROUP BY hour ORDER BY hour"
}
}' | jq '.results | map({hour: .[0], events: .[1]}) | .[-3:]'
Step 2: Instrument Flag Evaluation Latency
import { PostHog } from 'posthog-node';
const posthog = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: 'https://us.i.posthog.com',
personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
});
async function getFlag(flagKey: , : ): <> {
start = performance.();
value = posthog.(flagKey, userId);
durationMs = performance.() - start;
(, durationMs, { : flagKey });
(, , { : flagKey, : (value) });
(durationMs > ) {
.();
}
value;
}
{ , , } ;
flagDuration = ({
: ,
: ,
: [],
: [, , , , , , , ],
});
flagEvals = ({
: ,
: ,
: [, ],
});
() {
flagDuration.(labels, value);
}
() {
flagEvals.(labels, value);
}