Skip to content

PostHog

Overview

OpenSRE stores your PostHog project credentials for REST API access (project metadata and correlation). Configure with opensre integrations setup posthog or POSTHOG_* environment variables.

This REST integration does not register agent tools. For agent tools (analytics, feature flags, HogQL), use PostHog (MCP).

What you want Use Setup
Store PostHog REST credentials for your project PostHog (this page) opensre integrations setup posthog or env vars below
Let the agent explore PostHog during incidents PostHog (MCP) opensre integrations setup posthog_mcp
OpenSRE’s own product usage telemetry Built-in analytics Controlled by OPENSRE_NO_TELEMETRY — not your PostHog project

Prerequisites

  • A PostHog account (US, EU, or self-hosted)
  • Your PostHog project ID
  • A personal API key with read access to that project — see PostHog personal API keys

Setup

Option 1: Interactive CLI

opensre integrations setup posthog

In the interactive shell, use /integrations setup posthog or ask “Can you configure PostHog for me?”

  1. Choose US Cloud, EU Cloud, or your self-hosted app address. Setup links directly to that account's personal API key settings and explains the required read permissions before asking for a key.
  2. Choose your project by name. OpenSRE discovers the project ID for you. If it is not listed, you can retry, change the key or region, or enter the ID from project settings.
  3. OpenSRE verifies project access, saves the connection, and shows a summary. Failed checks can be retried in place; Ctrl+C cancels.

Use a personal API key (phx_...) with project:read for setup and query:read for analytics queries. A project capture key (phc_...) cannot read your analytics.

Option 2: Environment variables

POSTHOG_PROJECT_ID=your_project_id
POSTHOG_PERSONAL_API_KEY=phx_your_personal_api_key
POSTHOG_BASE_URL=https://us.posthog.com             # optional — US Cloud
POSTHOG_TIMEOUT_SECONDS=15.0                        # optional

Credentials

Variable Default Description
POSTHOG_PROJECT_ID — Required. Your PostHog project ID
POSTHOG_PERSONAL_API_KEY — Required. Personal API key for the project
POSTHOG_BASE_URL https://us.posthog.com App URL (https://eu.posthog.com for EU, or your self-hosted origin)
POSTHOG_TIMEOUT_SECONDS 15.0 HTTP timeout in seconds

Get the project ID from PostHog project settings. Create a personal API key (phx_...) with read access — see PostHog personal API keys.

Tools

This REST integration does not register agent tools. For agent tools (analytics, feature flags, HogQL), use PostHog (MCP).

Verify

opensre integrations verify posthog

A successful check prints PostHog validated.

For the MCP integration, use opensre integrations verify posthog_mcp instead.

Troubleshooting

Symptom Fix
Authentication failed (401) Check POSTHOG_PERSONAL_API_KEY is valid and has read access
Project not found (404) Confirm POSTHOG_PROJECT_ID matches the instance in POSTHOG_BASE_URL
Verify says not configured Both POSTHOG_PROJECT_ID and POSTHOG_PERSONAL_API_KEY must be set

Security

  • Use a dedicated personal API key with the minimum read permissions needed
  • Store credentials in environment variables or a secret manager — not in source code
  • Rotate keys periodically

Markdown source: View on AtomGit·Content from the open-source project op/opensre