Skip to content

feat(metrics): read the PostHog metrics3 schema - #5

Merged
frankh merged 3 commits into
mainfrom
posthog/metrics3-schema
Sep 15, 2026
Merged

frankh merged 3 commits into
mainfrom
posthog/metrics3-schema

Conversation

@frankh

@frankh frankh commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Why

Snuffle must read the metadata tables added in PostHog/posthog#100839, so metric name and label discovery no longer scans each series.

Changes

  • Default the PostHog layout to metric_series3, metric_attributes3, and metric_names3. Add the tables and their materialized views to the local schema script.
  • Metric names read metric_names3. Label names and values read metric_attributes3, also when every matcher is an exact __name__ or service_name match. Other matchers still read the series table.
  • Resource attributes now take precedence over metric attributes with the same key in the Prometheus label set. The README documents this and the 256 character limit on attribute keys and values that the rollup applies.
  • Add CH_ATTRIBUTE_TABLE_HAS_METRIC_NAME and accept an empty CH_METRIC_NAMES_TABLE, so the previous tables stay readable before the backfill completes.

How did you test this code?

  • make lint and make test pass.
  • make integration-test passes with both CH_SCHEMA_LAYOUT=posthog and CH_SCHEMA_LAYOUT=current. The e2e test covers exact metric and service filters, map label filters, attribute precedence, and reads from the previous tables.

Created with PostHog Desktop

Point the posthog layout at metric_series3 and metric_attributes3, add a
metric_names3 table for metric name discovery, and serve label names and
values for exact metric and service matchers from the attribute rollup
instead of a series scan. The local schema script creates the new tables
and their materialized views next to the existing ones.

Generated-By: PostHog Desktop
Task-Id: 97479d3a-d4b3-4b04-bd98-ee9f723c6c31
@frankh frankh self-assigned this Sep 15, 2026
@frankh
frankh marked this pull request as ready for review September 15, 2026 13:12
Generated-By: PostHog Desktop
Task-Id: 77a7e513-a8ea-4899-b570-8ba1bfad35f5
Read metric_attributes3 for label names and values when every matcher is
an exact __name__ or service_name match, guarded by
CH_ATTRIBUTE_TABLE_HAS_METRIC_NAME for the legacy table. Resource
attributes now take precedence over metric attributes in the Prometheus
label set, and the README documents that and the 256 character limit.

Generated-By: PostHog Desktop
Task-Id: 97479d3a-d4b3-4b04-bd98-ee9f723c6c31
@frankh
frankh merged commit 9e96482 into main Sep 15, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant