Anomaly detection and root cause analysis for BigQuery metrics

Metrics now run on BigQuery: detection, root cause and alerts, with a cap on what any query can scan. It is in testing until it has run on a live project, and this page says exactly what is and isn't proven.

Updated · Zello Labs

Status: in testing. Metrics run on BigQuery: Metron writes BigQuery SQL for detection, root cause and freshness checks, and those queries pass tests against an emulator built on Google’s own SQL engine. They have not yet run on a live project, which is the last step before BigQuery is called live. PostgreSQL is live today.

Metron is built to run anomaly detection and root cause analysis on metrics stored in Google BigQuery, the same way it does on PostgreSQL: a read-only service account, metrics defined by pointing at real columns, and each change judged against the metric’s own normal.

What you need before you connect

  • A Google Cloud project with the BigQuery datasets that hold the rows behind your metric.
  • A service account with BigQuery Data Viewer on those datasets and BigQuery Job User on the project, and its JSON key. Metron never writes to your warehouse.
  • A TIMESTAMP, DATETIME or DATE column on the table, so each row has a date. (GA4 exports keep time in an INT64 column; a view with TIMESTAMP_MICROS(event_timestamp) covers it.)
  • A column, or an expression over columns, that gives the value you want to track.
  • The columns you want to slice the metric by, such as region, plan or platform.
  • Optional: a language model endpoint you supply, for a more fluent write-up.

How do you connect BigQuery to Metron?

  1. Open Connections and choose BigQuery as the warehouse type.
  2. Enter your project ID and paste the service account’s JSON key.
  3. Save. Metron tests the connection before it stores anything, and a failed test saves nothing.
  4. Metron encrypts the key with a key only your install holds before storing it. API responses never include it, and deleting the connection deletes the stored key.

Each saved connection has a Test button, so you can confirm later that the key still works.

Browse your datasets and column types

The schema browser lists your datasets, the tables in each, and each column’s BigQuery type next to the type Metron detects (timestamp, numeric, categorical or boolean). You see at a glance which column can date a metric, which can carry its value, and which can slice it. Metron reads this from table metadata, which BigQuery doesn’t bill for.

Define a metric by pointing at real columns

The metric builder works the same way it does on PostgreSQL. You pick a dataset and a table from dropdowns filled from your warehouse, then:

  1. Choose the timestamp column from the table’s real columns.
  2. Write the value expression. It can be a single column or a CASE WHEN over columns.
  3. For a rate, add a denominator expression. Metron then treats the metric as a ratio.
  4. Tick the columns to slice by. Each one shows its detected type.
  5. Name the metric and save.

Metron suggests which columns are worth slicing by, from how many values each holds. It validates the expression when you save it. It checks every column name against the table’s real columns and allows arithmetic, CASE WHEN and a short list of functions. A column that doesn’t exist, a second statement or a subquery is rejected, and the error says what Metron found. The timestamp column and slice columns go through the same check.

What does BigQuery cost to run Metron on?

BigQuery bills by the bytes a query scans, so Metron is built to scan little:

  • A cap on every query. Each query carries a maximum: 20 GB by default, about $0.12 at on-demand prices, and adjustable. A query that would scan more fails with BigQuery’s own message instead of billing.
  • Only recent data on each check. A scheduled check re-reads the last week of each metric, not its whole history, and the full year once a day.
  • Only the partitions it needs. Queries filter the timestamp column directly, so BigQuery can skip partitions outside the window, and they read only the columns the metric uses.

What does an investigation return?

An investigation answers three questions in order. It starts when you run a check or when someone asks about a change.

Question What Metron reports
Is the change real? Expected value, actual value and the gap, judged against the same weekday over recent weeks
Where does it sit? The segment that holds most of the change, its share, and whether the rate changed or the mix shifted
What happened near it? Deploys and logged events close to the start of the change, with the time gap

Because Metron compares Mondays with Mondays, a normal Monday dip doesn’t count as a change. Read more about how removing the weekly pattern cuts false alarms. A new metric gets a simpler model until it has enough history.

For a rate such as conversion, the split between a rate effect and a mix effect tells you whether a segment’s own rate fell or its share of the volume changed. Deploys and releases arrive from GitHub by webhook. Anything else you add on the Events page, import from a spreadsheet, or send through Metron’s API.

An optional language model you supply words the findings in a few plain sentences. It sees the findings only, never your tables. Metron scores the “where” and the “when” claims separately and never states a cause. Follow-up questions are answered from the same evidence, and each write-up can go to Slack, a webhook or an email address.

Your data stays in BigQuery

Metron runs in your environment and reads BigQuery in place, with no pipeline copying your tables. The page on self-hosted root cause analysis covers what stays in your environment and what leaves.

Metron is in private beta, and we set up each team by hand. If your metrics live in BigQuery, tell us which metric you want to start with.

Common questions

Can Metron run anomaly detection on BigQuery?

Yes, in testing. Metron writes BigQuery SQL for every metric query and has passed tests against an emulator built on Google's own SQL engine. It has not yet run on a live project, so it is not called live. If BigQuery is where your metrics live, tell us in the beta form: you would be among the first.

What access does Metron need in BigQuery?

A service account with BigQuery Data Viewer on the datasets behind your metrics and BigQuery Job User on the project. Metron never writes. You enter your project ID and paste the service account's JSON key when you add the connection. Metron tests the connection before it saves anything, then stores the key encrypted.

Does Metron copy my BigQuery data?

No. Metron runs in your own environment and queries BigQuery in place. There is no replication pipeline and no second copy of your tables to keep in step. The language model you connect sees only the engine's findings, such as the segment and the size of the change. It never reads your rows.

How does root cause analysis work on BigQuery metrics?

Metron tests each segment of each column you chose to slice by against that segment's own history and reports which one holds most of the change. For a rate, it says whether the rate moved or the mix shifted. It then lists deploys and logged events near the start. It never claims cause.