Monitoring capture service

From PostHog/posthog · View interactive version

Monitoring capture service is an AI agent skill from the GitHub repository PostHog/posthog. Monitor and diagnose the capture service (rust/capture) in prod-us and prod-eu with verified metrics, Loki logs, dashboards and alerts. Use when investigating capture latency, errors, event loss, legacy (v0) versus v1 endpoint behavior, billing quota drops, the global rate limiter, event restriction

How to use this skill

Skill file

Monitoring the capture service

The capture service (rust/capture/) is PostHog's Rust HTTP intake.

It authenticates, validates and limits events, then produces them to Kafka or WarpStream.

One binary runs as four deployments, picked by CAPTURE_MODE.

Every name, label and value below was read from production (prod-us and prod-eu) and the code on master.

Counters only get a series after their first increment, so a missing series can mean "never happened" rather than "broken".

Confirm a name with the discovery tools before you conclude anything from an empty result.

Tools and datasources

Two tool sets reach the same data. Use either, and say which one you used.

| Tool set | Metrics | Logs | Notes |

| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| PostHog MCP (US project 2) | metric-names-list, metric-attributes-list, metric-attribute-values-list, then query-metrics with query.promql | logs-attribute-values-list, logs-attributes-list, then query-logs | Log service.name equals the namespace, for example capture-analytics. metric-names-list can report a counter as gauge; use rate or increase on counters anyway. |

| Grafana MCP (grafana-us, grafana-eu) | Prometheus datasource UID victoriametrics | Loki datasource UID P44D702D3E93867EC | Same UIDs in both regions. Profiles: Pyroscope datasource pyroscope (US). Dashboards: search_dashboards, get_dashboard_summary, get_dashboard_panel_queries. |

Ask which region to check when the user does not say. Query each region with its own tools; an environment label (prod-us, prod-eu) does not switch instances.

Health checks: keep zero-valued series (query.dropEmptySeries: false in PostHog) so a failing label still shows.

Deployments

| Namespace | Deployments | capture_mode label | Serves (paths seen in http_requests_total) | Produces to |

| ------------------- | ------------------------------------ | -------------------- | ---------------------------------------------------------------------------------------------- | -------------------------------------- |

| capture-analytics | capture-analytics-1a, -1b, -1c | events | Legacy /e, /batch, /capture, /i/v0/e, /track, /engage; v1 /i/v1/analytics/events | MSK ingestion cluster |

| capture-ai | capture-ai-1a, -1b, -1c | ai | Legacy /i/v0/ai, /i/v0/ai/batch, /i/v0/ai/otel; v1 /i/v1/ai/events | WarpStream (ingestion virtual cluster) |

| capture-replay | capture-replay-1a, -1b, -1c | recordings | /s | WarpStream (replay virtual cluster) |

| capture-import | capture-import | import | Same paths as analytics; only historical backfills are kept | MSK ingestion cluster |

Labels on capture metrics

Legacy (v0) versus v1: how to scope

| Question | Legacy (v0) | v1 |

| -------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |

| Requests and latency | http_requests_total, http_requests_duration_seconds_bucket with path!~"/i/v1/.*" | capture_v1_response_time_seconds_bucket{path=~"/i/v1/.*"} (or http_requests_total{path=~"/i/v1/.*"}, which counts v1 too) |

| Events in | capture_events_received_total (legacy only) | capture_v1_parsed_events{result} and capture_v1_event_batch_size |

| Events out to Kafka | capture_events_ingested_total (shared: one per acked message, both pipelines) | same metric; no per-pipeline split |

| Drops | capture_events_dropped_total{cause} | capture_v1_events_dropped{reason,stage}, per-request capture_v1_batch_outcomes{outcome} |

| Request errors | capture_error_by_stage_and_type{stage,error} | capture_v1_analytics_error{error,status_code,path} |

| Billing quota | capture_quota_limit_exceeded{resource} | capture_v1_events_quota_limited{resource}, whole-request capture_v1_analytics_error{error="billing_limit_exceeded"} (402) |

| Restrictions | capture_event_restrictions_applied{pipeline,restriction_type} (process-wide, counts both) | capture_v1_events_restricted{action} |

| Global rate limiter | capture_events_rate_limited_token_distinctid{reason} | capture_v1_rate_limiter{limiter,outcome} |

| Ingestion warnings | ingestion_warnings_total{path="legacy_analytics"} (also replay, ai_otel) | ingestion_warnings_total{path="v1_analytics"} |

| Logs | target not under capture::v1:: | target=~"capture::v1::.*", field path |

Metric catalog

Names with their facet labels. Paths are where the code emits them (rust/ prefix omitted).

HTTP and server (capture/src/metrics_middleware.rs, capture/src/server.rs, capture/src/extractors.rs)

Legacy event funnel (capture/src/payload/, capture/src/prometheus.rs, capture/src/sinks/producer.rs)

v1 pipeline (capture/src/v1/)

Billing quota (common/limiters/src/redis.rs, capture/src/quota_limiters.rs, capture/src/v1/quota_limiter_shim.rs)

Event restrictions (capture/src/event_restrictions/)

Global rate limiter (GRL) (common/limiters/src/global_rate_limiter.rs, scopes built in capture/src/global_rate_limiter.rs)

Overflow and partition limiter: partition_limits_key_count{lane} (common/limiters/src/overflow.rs), plus the reroute counters above.

AI lane (capture/src/otel/, capture/src/ai_endpoint.rs): capture_ai_otel_requests_total{format}, capture_ai_otel_requests_success, capture_ai_otel_spans_accepted, capture_ai_otel_spans_filtered, capture_ai_otel_events_ingested, capture_ai_otel_body_size_bytes. AI byte limits show as GRL *_ai_bytes scopes and the ai_byte_rate_limited drop cause.

Kafka producer, shared by every pipeline (capture/src/sinks/kafka.rs, capture/src/sinks/producer.rs)

Ingestion warnings (common/ingestion_warnings/src/): ingestion_warnings_total{path,source,type,outcome} (emitted, delivered, throttled, …), ingestion_warnings_throttle_keys, ingestion_warnings_emitter_enabled{reason}.

Redis dependencies

| Charts name | Env var | ElastiCache (prod-us / prod-eu) | Used by | Health source |

| --------------------------- | ----------------------------------------------- | ----------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |

| posthog (reader) | REDIS_URL | posthog-solo / posthog-prod-redis-encripted | billing limits, replay overflow set | redis_*{job="redis", instance="prometheus-redis-exporter.monitoring.svc.cluster.local:9121"}; EU also in aws_elasticache_* |

| ingestion (writer) | EVENT_RESTRICTIONS_REDIS_URL | ingestion-prod-redis | event restrictions | aws_elasticache_*{cache_cluster_id=~"ingestion-prod-redis.*"} |

| capture-globalratelimit | GLOBAL_RATE_LIMIT_REDIS_URL (+ _READER_URL) | capture-globalratelimit-prod-redis | GRL shard 0 (analytics, ai) | aws_elasticache_*{cache_cluster_id=~"capture-globalratelimit-prod-redis.*"} |

| capture-globalratelimit-2 | GLOBAL_RATE_LIMIT_REDIS_SHARD_1_URL | capture-globalratelimit-2-prod-redis | GRL shard 1 (analytics only) | aws_elasticache_*{cache_cluster_id=~"capture-globalratelimit-2-prod-redis.*"} |

| edge, not capture | — | ratelimit-prod-redis | Contour per-IP rate limit | aws_elasticache_*{cache_cluster_id=~"ratelimit-prod-redis.*"} |

Edge: Envoy and the rate limit service

Kafka topics and backends

| Topic (prod-us / prod-eu) | Producer | Backend (kminion instance) |

| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------- |

| ingestion-analytics-main-1024 / -512, ingestion-analytics-overflow-128, ingestion-analytics-historical-128, ingestion-analytics-team2-256 (US), ingestion-analytics-turbo-1024 (US) | analytics, import | MSK (kminion-msk-ingestion) |

| ingestion-heatmaps-main-128, ingestion-errortracking-main-128, ingestion-clientwarnings-main-16 / -32 | analytics | MSK (kminion-msk-ingestion) |

| ingestion-ai-msk-128 / -32, ingestion-ai-mskoverflow-32 / -8 | analytics ($ai_* sent to legacy or v1 analytics endpoints) | MSK, bridged to WarpStream |

| ingestion-ai-main-128 / -32, ingestion-ai-overflow-32 / -8 | capture-ai | WarpStream (kminion-warpstream-ingestion) |

| ingestion-sessionreplay-main-512 / -256 | replay | WarpStream (kminion-warpstream-replay) |

Logs

sum by (target, message) (count_over_time({namespace="capture-analytics", level=~"WARN|ERROR"} | json message="message", target="target" [1h]))
{namespace="capture-analytics"} | json | target=~"capture::v1::.*" | error_tag != ""

Dashboards and alerts

| UID | Title | Use for |

| --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------ |

| capture | Capture | Overview, start here (both regions) |

| capture-v1-details | V1 Details | v1 pipeline, GRL, restrictions, quota, GRL ElastiCache |

| ddfkdj56ds11xce | Legacy Details | Legacy pipeline, same shared sections |

| posthog-alerts-capture-analytics, -capture-v1, -capture-grl, -capture-replay, -capture-import, posthog-alerts-contour | Alerts: … | Generated alert boards |

| ratelimit-posthog | Rate Limit Service | Edge rate limit |

| contour, envoy-contour-debug | Contour Ingress, Envoy / Contour Debugging | Edge |

| dafu1z5geys4jkd, vm-redis | ElastiCache (Redis/Valkey), Redis | Redis health |

| ingestion-health, ingestion-analytics, ingestion-ai, ingestion-sessionreplay | Ingestion boards | Downstream consumers |

Kubernetes and profiling

Investigation playbooks

references/investigation-playbooks.md has step-by-step checks with tested queries: health, event loss (legacy and v1), latency, Kafka, quota and rate limiting, Redis, and cross-region comparison.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.