Skip to content

Reporting Cubes

padams edited this page Dec 2, 2026 · 1 revision

Every report in OWA 2.0 reads from a reporting cube: one table per Property, named owa_event_<property id>. Each row is an event from owa_event_raw together with the values a build derives for it, such as session source, channel, entrance and exit flags, and new vs returning. Data Model covers the tables themselves.

A cube is built by cmd=cube-rebuild and nothing else. Tracking writes only to raw. The scheduler runs the build. If the scheduler is not running, reports do not update and a new Property never gets a cube.

When cubes are built

The rebuild-cube job runs cmd=cube-rebuild every five minutes, at a minute offset per install. A run covers yesterday and today. A session still open at midnight gets its exit page from a run after it closes.

A scheduled run skips a partition when:

  • nothing has reached raw for that Property since the partition was last built, and that build came at least one session length (session_length, 30 minutes by default) after the newest arrival; or
  • it is empty both in raw and in the cube.

A partition that meets the first condition is still built once more if a build now would settle it. For example, a day whose last beacon came in the evening is rebuilt once after midnight.

A session that runs across midnight is one session on both days. A row that arrives later and continues one of a partition's sessions makes that partition due again. The next day's other traffic does not.

A run that finds a cube locked by another run skips it.

To change the cadence, retune the job in owa-config.php:

define( 'OWA_SCHEDULED_JOBS', array(
    'rebuild-cube' => array( 'schedule' => '0,15,30,45 * * * *' ),
) );

A new Property's first build

A cube is created on the Property's first data. On the first run after a Property has collected anything, rebuild-cube creates its cube and builds it back to the first day raw holds for that Property, including traffic collected before cron was set up. A Property that has never collected anything has no cube.

That first build reaches no further back than the Property's cube retention window (cube_retention_months, under Settings → Property → Data retention).

Catching up after a gap

A partition is settled when it was last built after its period ended and after the sessions open at that moment had timed out. Before it builds yesterday and today, a scheduled run walks back from yesterday to the first settled partition. It also builds every partition on the way that is unsettled, or empty while raw has rows for it.

Partitions are built oldest first, and a run stops at the first failure. The next run resumes where the last one stopped. After an outage, a stopped cron or a failing build, the next working run fills the gap.

Catch-up applies only to a run given no dates. A range you name is built exactly as named, including partitions that have not changed.

Running a build by hand

php cli.php cmd=cube-rebuild                                # yesterday and today, with catch-up
php cli.php cmd=cube-rebuild from=20260901                  # that date through to today
php cli.php cmd=cube-rebuild from=20260901 to=20260930      # a closed range
php cli.php cmd=cube-rebuild days=3                         # the last 3 days, today included
php cli.php cmd=cube-rebuild property=<id>                  # only that Property's cube
php cli.php cmd=cube-rebuild days=3 --dry-run               # print the statements, run nothing
php cli.php cmd=cube-rebuild steps=1                        # per-step timings and counts
Argument Value Default Description
from=<yyyymmdd> A date, yyyymmdd. First date to rebuild. With no to=, the range runs through today. With no dates at all, the range is yesterday and today, and a cube that is behind is caught up from its oldest unsettled partition.
to=<yyyymmdd> A date, yyyymmdd. Not before from=. Last date to rebuild, inclusive. With no from=, the range starts today.
days=<n> A whole number of at least 1. The last n days, today included. Ignored when from= or to= is given.
property=<id> An existing Property's id. Rebuild only this Property's cube, whether or not it has collected anything in the range.
--dry-run A switch. Print each partition's build statement, and change nothing. Says whether a missing cube would be created.
--steps A switch. After each partition, print the time and row count of every build step.

With no dates, the range is yesterday and today. With no property=, a run covers every existing cube, every Property with raw rows in the range, and every Property that has collected but has no cube yet.

The command requires the edit_modules capability.

The dates select partitions, not days. from=20260915 to=20260915 rebuilds whatever partition holds 15 September: one day in the cube's daily front, a whole month further back. The command prints what each range resolved to:

owa_event_3: 20260915 to 20260915 covers 1 partition(s).

A named range that reaches further back than the cube's oldest partition adds the partitions needed first, back to the start of the range or to the first day in raw, whichever is later.

Rebuild to apply a change to channel rules, the attribution lookback, a Profile's name or its Property to past data. Rebuilding an unchanged partition gives the same rows.

What a build of one partition does

  1. Adds any custom dimension columns that are waiting, and drops those of removed dimensions.
  2. Copies the partition's raw rows for the Property into a staging table, deriving the cube's columns. Raw is read at READ COMMITTED, without locks. A server whose binary log is statement-based keeps its own isolation level.
  3. Checks that the staging table holds exactly the raw rows of the partition. A row that reached raw while the build was reading is allowed, and the next run builds it in. Any other difference stops the build, and the live cube is unchanged.
  4. Swaps the staging table in for the partition (EXCHANGE PARTITION). Reports keep reading the old rows until that moment.

The swap waits at most 5 seconds for a report or other reader to finish with the cube. If the cube is still in use, the build stops with "the cube was in use; the next run swaps it", and the next scheduled run tries again.

A cube partition whose days are gone from raw (dropped with partition-drop only=raw) is not rebuilt. The command says so for each one.

Before a cube exists

A report for a Property with no cube shows a notice in place of the report:

Notice Cause What to do
This Profile belongs to no Property. Cubes are per Property. Assign the Profile to a Property.
Reports need the job scheduler. The scheduler is not running. Add the cron line the notice shows.
No reporting data yet. The scheduler is running and the first build with data has not happened. The notice says when the next build is due. Wait, or run cmd=cube-rebuild. Each Observation Profile's Tracking tag page shows whether data has arrived.

Under the notice are links to the Property's Observation Profiles and, for users with the edit_modules capability, to Reporting Cube status.

The REST API answers the same condition with HTTP 409 and a notReady object carrying the state and message. A report that is ready but has no rows answers 201 with an empty result.

Data as of

A report whose period reaches yesterday or today shows Data as of with a time in its header: the newest build time among the cube rows the report read. When the report's widgets read different build times, the header shows the oldest. A report of an earlier, closed period shows no time.

A recent time does not mean every day of the period is built. The line carries a warning when:

  • the scheduled build is not running; or
  • the last build stopped on this Property's cube.

Users with the edit_modules capability get a details link to that cube's page. The REST API returns the same time as asOf.

The Reporting Cubes screen

Settings → Server configuration → Reporting cubes lists every cube, and every Property that has collected but has no cube yet, worst first. It requires the edit_modules capability. It is read-only. Where something needs doing, it names the command.

The Reporting Cubes list

Each row shows a status badge, the Property and its table, the first check that is not OK, and a Details link. Each cube gets a set of checks, and its status is the worst of them:

Status Meaning
Action needed Reports are wrong, or will stop updating unless someone acts.
Attention Something is off that the next scheduled build, or time, will resolve.
OK Nothing to do.
Check Action needed Attention
Scheduled build The scheduler is not running, or the rebuild-cube job is not being run. —
Cube Not created yet, and the scheduler is down. Not created yet. Raw has data, and the next build creates it.
Last build The last run stopped on this cube. Shows the partition and the reason. The scheduled build has never run.
Built through Days before yesterday are unsettled, and the build is not reaching them. Days before yesterday are unsettled. The next run rebuilds from there.
Partitions Rows are in the catch-all partition, or the dated partitions end within 7 days. The dated partitions end within 30 days, or today is not in a daily partition.
Custom dimensions — A dimension is waiting for its column, or its column could not be added.

A cube's page

Details opens the cube's own page. It shows:

  • every check with its status and detail;
  • Last 14 days: for each day, raw rows, cube rows, the partition holding it, when it was last built, and whether it is settled. A settled day whose cube rows differ from raw is marked differs from raw;
  • Partitions: how many there are, how far back they reach, how far the daily partitions run, where the dated partitions end, and how many rows are in the catch-all;
  • Commands: the cmd=schedule-status and cmd=cube-rebuild lines for this Property. A build cannot run from the screen.

One cube's page: checks, the last 14 days, partitions and commands

A day where raw has rows and the cube has none, or where the two disagree on a settled day, is a gap. Rebuild it with cmd=cube-rebuild property=<id> from=<day> to=<day>.

Partitions

A cube is partitioned by day of event (yyyymmdd), in two tiers:

  • About two months of daily partitions around today.
  • Ten further months of lead at the granularity the rest of the table uses (monthly unless you have reorganized it).

The daily rotate-partitions job (cmd=partition-rotate) keeps this shape. It merges the daily partitions of a finished period back into one, carves the next period into days, extends the lead, and drops partitions older than the retention window. Each partition change waits at most 5 seconds for the table. If the table is in use, that change is skipped and the next run tries again.

Two partition states need action:

  • Rows in the catch-all (Action needed). The dated partitions ran out and rows landed in the final MAXVALUE partition, which no build can rebuild. Run cmd=partition-rotate and check that its job runs.
  • Today is not in a daily partition (Attention). Every build then rewrites a whole period. cmd=partition-rotate carves the daily front back.

partition-reorganize leaves a cube's daily front alone and refuses granularity=daily for a cube.

Adding columns to a cube

Two things add a column to every cube, or to one cube:

  • a release whose schema update adds a column to raw, which every cube also needs;
  • registering a custom dimension, which adds a column to that Property's cube.

Adding a cube column rewrites the whole table. Reads and writes continue while it runs. On a large cube it takes minutes and heavy I/O.

Custom-dimension columns are never added inside the request that registers them. The apply-custom-dimensions job adds pending columns every 15 minutes, and each build adds them before it starts. Several pending columns go in one rewrite.

A column added to a cube by hand is added instantly by default on MySQL 8 and MariaDB. The next build then fails at the swap with an error naming MySQL error 1731. The fix is the one the error gives:

ALTER TABLE owa_event_<property id> FORCE;

Troubleshooting

Reports say "No reporting data yet" or "Reports need the job scheduler".

  1. Check the scheduler:
    php cli.php cmd=schedule-status
    If the dispatcher has never run, the output says so and prints the crontab line to add.
  2. Check that data is arriving: each Observation Profile's Tracking tag page shows when the last event was received.
  3. To build straight away:
    php cli.php cmd=cube-rebuild

"Data as of" is old, or carries a warning. Open Settings → Server configuration → Reporting cubes. The Last build check shows where the run stopped and why. cmd=schedule-status shows the same message for the rebuild-cube job. Once the cause is fixed, the next scheduled run resumes from that partition.

A build fails with "built N rows from M raw rows. Not swapped." The live cube is unchanged. Rerun with steps=1 to see which step misbehaved, and report it with the output.

A build stops with "the cube was in use; the next run swaps it". A report or other reader held the cube for longer than the swap waits. Nothing was changed, and the next scheduled run tries again. If it recurs, look for long-running queries against the cube.

A build says "No dated partition … covers …". The cube's dated partitions do not reach the range. Run cmd=partition-rotate to extend the lead.

The run reports raw rows that "belong to a site id no Property claims". Those rows are in no cube. Either a Profile was deleted while its rows remain, or beacons quoted a site id that was never issued.

"Another build of … is already running". Another run holds that cube's lock. The lock lapses 30 minutes after the run's last partition finished, including when the run crashed.

Changes from 1.x

After an upgrade from 1.x, the first build covers all migrated history and takes far longer than later runs. As a rough guide, allow 1.5 to 3 minutes per 100,000 events.

Clone this wiki locally