Install metrics
Contents
Note: Metrics is in private alpha and the viewer is only turned on for selected teams, so you may not be able to view metrics you send yet. Setup details, including the ingestion endpoint, may change before general availability.
There are three ways to get metrics into PostHog:
- PostHog SDKs: if a PostHog SDK is already in your app, record metrics with the
posthog.metricsAPI. No new packages, no extra authentication. - OpenTelemetry (OTLP): if you use OpenTelemetry anywhere else, point your OTLP metrics exporter at PostHog. No PostHog packages required.
- Metrics agent: if your services already expose Prometheus
/metricsendpoints, run the PostHog metrics agent with Docker or the Kubernetes Helm chart to scrape and forward them, with no code changes.
Already capturing metrics with Prometheus, StatsD, or Datadog? You don't need to replace anything: add the PostHog call next to your existing instrumentation, using the same metric name and attributes, and migrate at your own pace.
Platforms
| Platform | Method |
|---|---|
| JavaScript (web) | posthog.metrics API in posthog-js |
| Node.js | posthog.metrics API in posthog-node |
| Python | posthog.metrics API in posthog-python |
| Other languages | Any OpenTelemetry-compatible OTLP metrics exporter |
| Docker | Metrics agent container that scrapes Prometheus /metrics targets |
| Kubernetes | Helm chart that scrapes prometheus.io/scrape annotated pods |
Note: Metrics uses the OpenTelemetry Protocol (OTLP) standard. If your language isn't listed, check the OpenTelemetry documentation for compatible libraries and see other languages.