:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(mcp): address greptile feedback on querying-posthog-data refs (#59117)
Daniel Visca72391bbef1a4
diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-logs.md b/products/posthog_ai/skills/querying-posthog-data/references/models-logs.mdindex 7b10c27b190e..9a9a97c184a2 100644--- a/products/posthog_ai/skills/querying-posthog-data/references/models-logs.md+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-logs.md@@ -32,11 +32,11 @@ OpenTelemetry log entries. One row per log line. Backed by ClickHouse `logs_dist### Sort key-`(team_id, service_name, toUnixTimestamp(timestamp))`. Queries that filter on `service_name` + a time window are very efficient. **Never query without a `service_name` (or `resource_attributes` filter) and a time window** — unfiltered queries can scan terabytes.+`(team_id, service_name, toUnixTimestamp(timestamp))`. Queries that filter on `service_name` + a time window are very efficient. **Never query without a `service_name` filter and a time window** — unfiltered queries can scan terabytes. `resource_attributes` is a Map column outside the sort key, so a `resource_attributes` filter alone does **not** prune granules the way `service_name` does and is no substitute for it.### Important notes-- **`trace_id` and `span_id` are base64-encoded bytes**, not hex. The displayed hex form (e.g. `21EDB3A025A9ECD32ADF3E5D7548A4F4`) comes from the API layer via `hex(tryBase64Decode(trace_id))`. Raw HogQL queries see the 24-character base64 form (e.g. `21EDB3A025A9ECD32ADF...` becomes `IepzoCWp7NMq3z5ddUik9A==`).+- **`trace_id` and `span_id` are base64-encoded bytes**, not hex. The displayed hex form (e.g. `21EDB3A025A9ECD32ADF3E5D7548A4F4`) comes from the API layer via `hex(tryBase64Decode(trace_id))`. Raw HogQL queries see the 24-character base64 form (e.g. `21EDB3A025A9ECD32ADF3E5D7548A4F4` becomes `Ie2zoCWp7NMq3z5ddUik9A==`).- **Unset `trace_id` is `'AAAAAAAAAAAAAAAAAAAAAA=='`** (16 zero bytes encoded), not the hex zero-padded form. Use `trace_id != 'AAAAAAAAAAAAAAAAAAAAAA=='` to find logs with trace context. Or use the explicit decode: `tryBase64Decode(trace_id) != unhex('00000000000000000000000000000000')`.- **Use `hex(tryBase64Decode(trace_id))` to display trace_ids in hex** for human-readable output.- **Prefer `severity_text` over `severity_number` / `level`** for human-readable filters.@@ -173,7 +173,7 @@ If you already have the trace_id in base64 form (e.g. selected directly from the```sqlSELECT timestamp, severity_text, service_name, bodyFROM logs-WHERE trace_id = 'IepzoCWp7NMq3z5ddUik9A=='+WHERE trace_id = 'Ie2zoCWp7NMq3z5ddUik9A=='ORDER BY timestamp```diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-metrics.md b/products/posthog_ai/skills/querying-posthog-data/references/models-metrics.mdindex ec34e69b7d06..93c71c69d8c9 100644--- a/products/posthog_ai/skills/querying-posthog-data/references/models-metrics.md+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-metrics.md@@ -93,13 +93,13 @@ GROUP BY metric_name, metric_typeORDER BY n DESC```-**Per-minute mean value of a metric, broken down by service (projection-friendly):**+**Per-minute mean value of a non-histogram metric, broken down by service (projection-friendly — `count = 1` per row, so `count()` maps to the projection's `event_count`):**```sqlSELECTtoStartOfMinute(timestamp) AS minute,service_name,- sum(value) / sum(count) AS mean_value+ sum(value) / count() AS mean_valueFROM posthog.metricsWHERE metric_name = 'http.server.duration'AND timestamp >= now() - INTERVAL 1 HOUR@@ -107,6 +107,8 @@ GROUP BY minute, service_nameORDER BY minute, mean_value DESC```+The `projection_aggregate_counts` projection stores `count() AS event_count` and `sum(value) AS total_value`. `sum(count_column)` (the per-row UInt64) is **not** in the projection — using it forces a base-table scan. For histograms (where `count` per row is the bucket observation count), compute the mean separately and don't expect projection acceleration.+**Top services by counter rate in the last hour:**```sql