AGENTIC MEMORY

Skills

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

← Back to Skills

instrument-logs

Add PostHog log capture to track application logs. Use after implementing features or reviewing PRs to ensure meaningful log events are captured with structured properties. Also handles initial OTLP exporter setup if not yet configured.

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--instrument-logs 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 · 19

references/mcp.md

AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt

Use Logs over PostHog MCP

Canonical URL: https://posthog.com/docs/logs/surfaces/mcp

On this page

The PostHog MCP server gives coding agents direct access to your logs. Ask your agent to search, filter, and analyze log data without leaving your editor, then fix the bug in the same session.

This works in any MCP client – Cursor, Codex, Claude Code, Windsurf, VS Code, and others.

Before you start

  1. Set up Logs – send them to PostHog with an OpenTelemetry client so there's something to read.
  2. Connect the MCP server – install it in your AI tool and give it access to your project.

What you can do here

Through MCP tools, your agent can:

  • Query and count logs – filter by severity, service, time range, and free text, and pull counts or sparklines to see how a problem is trending.
  • Discover what's available – list log attributes and their values, and list the services sending logs with their volume and error rate, so it can build a targeted query instead of guessing.
  • Break counts down by facet – group matching logs by any attribute to see where a spike is concentrated.
  • Mine and diff patterns – group similar log lines into templates, and compare two time ranges to see which patterns are new or spiking.
  • Manage alerts – create, read, update, and delete log alerts, attach or remove Slack, webhook, and Teams destinations, read an alert's event history, and simulate a threshold against historical logs before committing to it.

Saved views, sampling rules, and metric rules aren't exposed over MCP – manage those in the web app or with the Logs API.

For the full list of tools and how to scope a session to a subset, see the MCP tools reference.

Example prompts

| Goal | Ask your agent | | --- | --- | | Triage | Show me all error logs from the last hour | | Narrow by service | What services are logging errors? Search for error logs from the payments service | | Follow a request | Find logs related to trace ID abc123 | | Explore the schema | What log attributes are available? Show me the values for service.name | | Spot what changed | Compare log patterns from today against yesterday and show me what's new | | Cut noise | Show me warning and error logs from the last 24 hours, excluding debug noise |

Because your agent has both your codebase and your logs in one session, it can connect a log line to the exact code path that emitted it and draft the fix.

A useful order of operations: list attributes and their values to learn the schema, count matching logs to check the result set is a sane size, then query. Log records carry trace and span IDs, so your agent can follow a single request across services.

Set up

Connect the PostHog MCP server to your AI tool of choice, then grant it access to your project. The MCP overview covers install and authentication for each client.

To browse logs visually, mine patterns interactively, or watch the session replay behind a log line, use the web app.

Related