AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

querying-posthog-data

Explains how to query PostHog data, defaulting to typed runners for supported product analytics. Read it before you write HogQL/SQL. Also read it before you call execute-sql against PostHog. Use it to find or aggregate PostHog entities. These entities include insights, dashboards, cohorts, feature flags, experiments, surveys, hog flows, warehouse data, and persons. Use it for trends, funnels, retention, lifecycle, paths, stickiness, web analytics, error tracking, logs, sessions, and LLM traces. Before you calculate a governed business or telemetry measure, check system.information_schema.metrics for an approved definition. Examples include MRR, activation, billable usage, active organizations, and failure rates. Use the approved definition before you derive a measure from raw events or use a typed domain tool. It also covers HogQL differences, system table schemas, functions, query examples, and schema discovery.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--querying-posthog-data at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 65

references/models-batch-exports.md

Batch exports

BatchExport (system.batch_exports)

Batch exports define recurring data export jobs that send events, persons, or sessions to external destinations.

Columns

| Column | Type | Nullable | Description | | ----------------- | ----------------- | -------- | -------------------------------------------------------------------------------- | | id | uuid | NOT NULL | Primary key | | team_id | integer | NOT NULL | Team this export belongs to | | name | text | NOT NULL | Human-readable name | | model | varchar(64) | NULL | Data model: events, persons, or sessions | | interval | varchar(64) | NOT NULL | Schedule frequency: hour, day, week, every 5 minutes, every 15 minutes | | paused | integer | NOT NULL | Whether the export is paused (1 = paused, 0 = active) | | deleted | integer | NOT NULL | Soft-delete flag (1 = deleted, 0 = active) | | destination_id | uuid | NOT NULL | FK to the destination configuration (not queryable as a system table) | | timezone | varchar(240) | NOT NULL | IANA timezone for scheduling (e.g. UTC, America/New_York) | | interval_offset | integer | NULL | Offset in seconds from the default interval start time | | created_at | timestamp with tz | NOT NULL | Creation timestamp | | last_updated_at | timestamp with tz | NOT NULL | Last modification timestamp | | last_paused_at | timestamp with tz | NULL | When the export was last paused | | start_at | timestamp with tz | NULL | Earliest time for scheduled runs | | end_at | timestamp with tz | NULL | Latest time for scheduled runs |

Key Relationships

  • Each batch export belongs to a Team (team_id)
  • Backfills reference this table via system.batch_export_backfills.batch_export_id

Important Notes

  • Filter with deleted = 0 to exclude soft-deleted exports
  • Filter with paused = 0 to find actively running exports
  • Destination details (type, connection config) are not in this table; use the batch-export-get MCP tool instead
  • Run history is not directly queryable via SQL; batch-export-get returns the 10 most recent runs in latest_runs — for older runs use the PostHog UI (the runs endpoints are not exposed as MCP tools)

BatchExportBackfill (system.batch_export_backfills)

Backfills are one-time historical data export jobs triggered for a batch export.

Columns

| Column | Type | Nullable | Description | | --------------------- | ----------------- | -------- | --------------------------------------------------- | | id | uuid | NOT NULL | Primary key | | team_id | integer | NOT NULL | Team this backfill belongs to | | batch_export_id | uuid | NOT NULL | FK to the parent batch export | | start_at | timestamp with tz | NULL | Start of the backfill time range | | end_at | timestamp with tz | NULL | End of the backfill time range | | status | varchar(64) | NOT NULL | Current status (see values below) | | created_at | timestamp with tz | NOT NULL | Creation timestamp | | finished_at | timestamp with tz | NULL | Completion timestamp | | last_updated_at | timestamp with tz | NOT NULL | Last modification timestamp | | total_records_count | bigint | NULL | Total records exported (populated after completion) |

Key Relationships

  • Each backfill belongs to a BatchExport (batch_export_id → system.batch_exports.id)
  • Each backfill belongs to a Team (team_id)

Important Notes

  • Status values: Starting, Running, Completed, Failed, FailedRetryable, Cancelled, ContinuedAsNew, Terminated, TimedOut
  • A NULL start_at means backfilling from the earliest available data
  • A NULL end_at means backfilling up to the current time