AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill guides the integration of PostHog log capture into various application stacks. It automates the setup of OTLP exporters and provides instructions for adding structured logging alongside existing application logs. The skill ensures that log events are captured with meaningful properties, facilitating better observability and debugging within the PostHog platform.
What it does
- Detects the application platform and existing logging infrastructure.
- Configures the OpenTelemetry (OTLP) exporter for PostHog ingestion.
- Integrates PostHog log capture without replacing existing logging handlers.
- Ensures logs are captured with structured key-value properties.
- Manages environment variable configuration for API tokens and host URLs.
- Provides platform-specific guidance for SDK-native log capture.
When to use it
- After implementing new features that require observability.
- During code reviews when you identify a need for better log coverage.
- When setting up initial log export for a new project.
- When migrating from standard logging to structured, centralized log management.
Advantages
- Maintains existing logging architecture without disruptive changes.
- Supports a wide range of languages and frameworks via OpenTelemetry.
- Enables structured logging for improved search and filtering in PostHog.
- Automates the configuration of environment variables and ingestion endpoints.
Usage examples
- “Add PostHog log capture to my Node.js application.”
- The agent will analyze your package.json, install necessary OpenTelemetry dependencies, configure the OTLP exporter, and guide you through adding PostHog logging calls to your code.
- “I need to start tracking logs in my Android app using PostHog.”
- The agent will verify your Android SDK setup, configure the PostHogAndroidConfig for logs, and show you how to use PostHog.logger to capture structured events.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/posthog/instrument-logs/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip instrument-logs.zip -d .agents/skills
Documentation by PostHog
Add PostHog log capture
Use this skill to add PostHog log capture for new or changed code. Use it after implementing features or reviewing PRs to ensure meaningful log events are captured with structured properties. If PostHog log export is not yet configured, this skill also covers initial OTLP exporter setup. Supports any platform or language.
Supported platforms: Next.js, Node.js, Python, Go, Java, Datadog, Android, React Native, iOS, and any language via OpenTelemetry.
Instructions
Follow these steps IN ORDER:
STEP 1: Analyze the codebase and detect the platform.
Detect the language, framework, and existing logging setup.
Look for dependency files and project files (package.json, Podfile, Package.swift, requirements.txt, go.mod, pom.xml, etc.).
Look for log libraries (winston, pino, logging module, logrus, log4j, serilog, os_log, Logger, etc.).
Look for lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb, go.sum, Podfile.lock, Package.resolved, etc.) to determine the package manager.
Check for existing PostHog log export setup. If the OTLP exporter is already configured, skip to STEP 5 to add log capture for new code.
STEP 2: Research log capture. (Skip if PostHog log export is already configured.) 2.1. Find the reference file below that matches the detected platform — it is the source of truth for OTLP exporter configuration and integration with existing logging. Read it now. 2.2. If no reference matches, use the "Other Languages" reference as a fallback — it covers the generic OpenTelemetry approach.
STEP 3: Install dependencies. (Skip if PostHog log export is already configured.)
Install the OpenTelemetry SDK and OTLP exporter packages for the detected platform.
Do not manually edit dependency files — use the package manager's install command.
STEP 4: Configure the OTLP exporter. (Skip if PostHog log export is already configured.)
PostHog logs use the OpenTelemetry protocol. Set up an OTLP exporter pointed at PostHog's ingest endpoint.
For SDK-native log support such as Android, React Native, and iOS, follow the platform reference instead of adding a separate OTLP exporter.
Follow the platform-specific reference for the exact configuration.
STEP 5: Integrate with existing logging.
Add the PostHog log exporter alongside existing logging. Don't replace existing log handlers or outputs.
Do not alter the fundamental architecture of existing files. Make additions minimal and targeted.
You must read a file immediately before attempting to write it.
STEP 6: Add structured properties.
Ensure logs include structured key-value properties for filtering and search in PostHog.
Prefer structured log formats with key-value properties over plain text messages.
STEP 7: Set up environment variables.
Check if the project already has PostHog environment variables configured (e.g. in
.env,.env.local, or framework-specific env files). If valid values already exist, skip this step.If the PostHog project token is missing, use the PostHog MCP server's
projects-gettool to retrieve the project'sapi_token. If multiple projects are returned, ask the user which project to use. If the MCP server is not connected or not authenticated, ask the user for their PostHog project token instead.For the PostHog host URL: check the
projects-getMCP response for aregionfield —USmaps tohttps://us.i.posthog.com,EUmaps tohttps://eu.i.posthog.com. If the region is not available from the MCP response or from existing project configuration, ask the user: "Are you on PostHog US Cloud or EU Cloud?" Do not assume US Cloud.For the OpenTelemetry endpoint, use
https://us.i.posthog.com/v1(US) orhttps://eu.i.posthog.com/v1(EU), matching the region determined above.Write these values to the appropriate env file using the framework's naming convention.
Reference these environment variables in code instead of hardcoding them.
Reference files
references/nextjs.md- Next.js logs installationreferences/nodejs.md- Node.js logs installationreferences/python.md- Python logs installationreferences/go.md- Go logs installationreferences/java.md- Java logs installationreferences/datadog.md- Datadog logs installationreferences/android.md- Android logs installationreferences/react-native.md- React native logs installationreferences/ios.md- Ios logs installationreferences/flutter.md- Flutter logs installationreferences/other.md- Other languages logs installationreferences/start-here.md- Getting started with logsreferences/search.md- Search logsreferences/best-practices.md- Logging best practicesreferences/troubleshooting.md- Logs troubleshootingreferences/link-session-replay.md- Link session replayreferences/mcp.md- Use logs over PostHog mcpreferences/COMMANDMENTS.md- Framework-specific rules the integration must follow
Each platform reference contains specific OTLP configuration, SDK setup, and integration patterns. Find the one matching the user's stack.
Key principles
Environment variables: Always use environment variables for PostHog keys and OpenTelemetry endpoints. Never hardcode them.
Minimal changes: Add log export alongside existing logging. Don't replace or restructure existing logging code.
OpenTelemetry: PostHog logs use the OpenTelemetry protocol. Configure an OTLP exporter pointed at PostHog's ingest endpoint unless the platform SDK provides native log capture.
SDK-native logs: For Android, React Native, and iOS, use the SDK logger/capture APIs from the platform reference instead of adding a separate OTLP exporter.
Structured logging: Prefer structured log formats with key-value properties over plain text messages.
Files
- ATTRIBUTION.mdAdded by AutoGineer931 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md6.1 KiB
- references/COMMANDMENTS.md1.5 KiB
- references/android.md9.2 KiB
- references/best-practices.md25.2 KiB
- references/datadog.md3.8 KiB
- references/flutter.md20.4 KiB
- references/go.md4.9 KiB
- references/ios.md11.1 KiB
- references/java.md4.7 KiB
- references/link-session-replay.md6.4 KiB
- references/mcp.md4.1 KiB
- references/nextjs.md6.9 KiB
- references/nodejs.md4.8 KiB
- references/other.md3.5 KiB
- references/python.md4.7 KiB
- references/react-native.md10.8 KiB
- references/search.md8.0 KiB
- references/start-here.md10.2 KiB
- references/troubleshooting.md6.5 KiB
references/search.md
AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
Search logs
Canonical URL: https://posthog.com/docs/logs/search
Cloud region: This page uses US Cloud hosts. For an EU Cloud project, use
https://eu.posthog.cominstead ofhttps://app.posthog.com(app host for links).
On this page
Facet rail
Filter bar
Filter on resource attributes and attributes
Filter by severity, trace ID, and span ID
Full-text search on Message
Filter from the facet rail
Pivot from patterns to matching logs
Tips
There are two ways to filter logs on the logs page: the facet rail on the left sidebar and the filter bar at the top.
Facet rail
The facet rail is a sidebar on the left side of the logs viewer. It shows curated filters you can click to narrow results without typing in the filter bar.
Two facets always appear:
Level – filter by log severity (
trace,debug,info,warn,error,fatal)Service – filter by
service.name
Additional facets appear automatically when your logs contain common OpenTelemetry resource attributes:
| Facet | Resource attribute | Group |
|---|---|---|
| Environment | deployment.environment.name | Standard |
| Namespace | k8s.namespace.name | Kubernetes |
| Deployment | k8s.deployment.name | Kubernetes |
| Pod | k8s.pod.name | Kubernetes |
| Node | k8s.node.name | Kubernetes |
| Host | host.name | Infrastructure |
These facets are presence-gated — they only show up when your logs actually contain the corresponding resource attribute. For example, the Kubernetes facets won't appear if your services don't emit Kubernetes metadata.
Filter bar
The filter bar at the top of the logs page lets you build precise filters. Pick a field, choose an operator, and enter a value. Add as many filters as you need — they're combined with AND.
There are four kinds of fields you can filter on in the filter bar:
Logs – top-level log properties:
severity_level,trace_id, andspan_idMessage – full-text search over the log body
Resource attributes – describe where the log came from, like
service.name,host.name, ork8s.container.nameAttributes – custom key-value context attached to individual log events, like
user_id,endpoint, orstatus_code
Filter on resource attributes and attributes
Resource attributes identify the source of a log (the service, host, or container that emitted it). Attributes describe a specific log event. Both come from your OpenTelemetry instrumentation — the richer your structured logging, the more you can filter on.
To filter:
Click the filter bar and pick a field. Resource attributes and attributes are grouped separately in the picker.
Choose an operator (equals, contains, is set, greater than, etc.).
Enter a value.
For example, filter service.name equals checkout-api to scope to one service, then add status_code equals 500 to narrow to failed requests.
Filter by severity, trace ID, and span ID
The Logs group in the filter picker exposes three top-level fields. All three only support equals and not-equals operators.
severity_level – filter by log severity using a dropdown. Available values:
trace,debug,info,warn,error,fatal.trace_id – filter logs by their OpenTelemetry trace correlation ID. Accepts hex or base64 format trace IDs
span_id – filter logs by their OpenTelemetry span ID. Accepts hex or base64, same as
trace_id.
For example, copy a trace_id from a trace URL and paste it into the filter to see every log emitted during that trace.
Full-text search on Message
To search log bodies, pick the Message field from the filter bar. Message supports three operators, each with a negated variant for exclusion:
| Operator | Behavior |
|---|---|
equals / doesn't equal | Exact match. Case-sensitive. |
contains / doesn't contain | Substring match. Case-insensitive. The default. |
matches regex / doesn't match regex | RE2 regex. Case-insensitive. |
Examples
Contains
failed to connect– matches any log containing that substring, regardless of case.Equals
Health check OK– matches only logs whose body is exactly that string.Matches regex
timeout|refused|reset– matches logs mentioning any of those words (useful when you'd otherwise add multiple contains filters).Doesn't contain
healthcheck– exclude noisy healthcheck lines while keeping everything else.
Filter from the facet rail
The facet rail is a sidebar on the left of the logs page that displays available log fields grouped by category. Each facet group shows the available values for that field along with their counts, helping you explore your log data at a glance.
Clicking a facet value cycles through three states:
Unchecked → Included – shows only logs matching that value.
Included → Excluded – hides logs matching that value.
Excluded → Unchecked – clears the filter.
The Level facet and resource-attribute facets (like Environment and Namespace) support this tri-state cycle. You can include one severity level while excluding another in the same query — for example, include error to focus on errors while excluding debug to remove noise.
Search facets
When the facet rail contains many fields, use the search input at the top to find the facet you need. Type a field name or group name and the rail filters to show only matching facets. Empty groups are hidden automatically.
The facet search:
Matches field titles and group names (case-insensitive)
Persists in the URL so you can bookmark or share your filtered view
Clears when you remove the search text
Pivot from patterns to matching logs
The Patterns view mines your logs into recurring message templates. When you expand a pattern, click View matching logs to pivot to the Logs view filtered to lines matching that pattern.
The pivot applies a message filter based on the pattern's template:
Regex filter – when the pattern has a validated regex, it lands as a
matches regexmessage filter. The regex is compiled from the template's structure and validated against the pattern's own examples before it ships.Contains filter – when the regex can't be validated (e.g. examples diverge from the template), the pivot falls back to a
containsfilter using the pattern's longest literal text.
The applied filter appears in the filter bar as a visible, removable chip — it behaves like any filter you'd add manually. Your existing date range, service, and severity selections are preserved so the pivot stays inside your investigation context.
When the pattern's sample is unambiguous (a single service or severity), the pivot also scopes by those values to narrow the scan.
Tips
Stack filters to narrow down. Every filter you add is ANDed together — combine a
service.namefilter with a Message contains to scope full-text search to one service.Start with contains, then tighten. Contains is case-insensitive and forgiving. Switch to equals only when you need an exact match, or regex when you want OR-style matching in a single filter.
Use regex for alternatives. Instead of adding three contains filters, use one regex like
(timeout|refused|reset).Structured logs make filtering more powerful. Key-value context like
user_id,endpoint, andstatus_codebecomes an attribute you can filter on directly. See our logging best practices for patterns that make logs easier to query.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs Python, Needs Node.js
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/omnibus/instrument-logs · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download instrument-logs.zip