Best practice: Safely deploying and monitoring PDT changes

In Looker, a persistent derived table (PDT) that fails to build blocks every dashboard, scheduled delivery, alert, and API query that depends on it. This document describes best practices for deploying and monitoring PDT changes:

  • Catch PDT build failures before you deploy by validating PDT changes in Development Mode and testing PDTs with Continuous Integration (CI).
  • Detect production issues quickly by configuring System Activity alerts.
  • Resolve outages quickly by maintaining a rollback plan.

Deployment readiness checklist

Before you deploy PDT changes to production, verify that your project and Looker instance meet the criteria described in the following sections:

Validate PDT changes before you deploy

Before you merge and deploy changes to a PDT, validate that the table builds in your database by testing it in Development Mode and running the Looker CI SQL Validator, as described in the following sections.

Build the PDT in Development Mode

Any change to a PDT's SQL, increment_key, or dependencies produces a new table that Looker must build completely. Before you merge your changes, complete the following steps:

  1. In Development Mode, run a query in an Explore that uses the changed PDT, or select Rebuild Derived Tables & Run from the Explore actions gear menu. Looker builds a development copy of the table with the same SQL that runs in production and displays any database error in the Explore.

  2. Resolve any errors and confirm that the development build completes before you merge your branch.

Run the Looker CI SQL Validator on branches that change PDTs

The Looker CI SQL Validator builds any PDT that an Explore depends on before running the validation query for that Explore, so a PDT whose SQL fails in the database fails validation before deployment.

Monitor PDT builds in production

PDTs can also start failing after deployment because of schema drift, data growth, or data warehouse quota changes. To detect these failures sooner, configure the two System Activity alerts that are described in the following sections.

Because alerts attach to dashboard tiles, create each of the following alerts on a dashboard tile:

  1. Save the System Activity Explore as a tile on a dashboard, such as a PDT Health dashboard.

  2. Hold the pointer over the tile, and click the Alerts (bell) icon.

  3. Select Create alert. If the tile already has alerts, select New.

The account that creates the alert needs the see_system_activity permission. Because alerts run with their creator's permissions, create these alerts by using an admin or service account that won't be deactivated.

Alert A: Repeated PDT build failures

Configure the first alert on the System Activity > PDT Event Log Explore with the following settings:

Setting Value
Dimensions PDT Event Log > View Name, Model Name, Connection
Measure PDT Create Failures
Filter Created Time is in the last 1 hour; PDT Create Failures is greater than 0
Alert PDT Create Failures is greater than 5 on any row, check every 15 minutes, Advanced > Send every time the condition is met

Alert B: Query queue time

Configure the second alert on the System Activity > Query Performance Metrics Explore with the following settings:

Setting Value
Dimensions History > Source
Measures Query Metrics > Timings: Queue > Queued Average, Query Metrics > Counts > Count Queued Query Events
Filter Query Metrics > Created At Time is in the last 30 minutes
Alert Queued Average is greater than 60 (seconds) on any row, check every 15 minutes, Advanced > Send every time the condition is met

On a healthy instance, queue time is typically less than one second. Sustained queue time indicates that query workers are exhausted. Tune the threshold to fit your instance.

After any deployment that modifies PDTs, also check Admin > Database > Persistent Derived Tables for current build status and recent failures.

Have a rollback plan

Prepare a rollback procedure before you deploy PDT changes so that you can restore service quickly if a production build fails:

  • Deploy production from Git tags by using advanced deploy mode so that rolling back requires only a single redeployment of the previous tag. To redeploy, use the deploy webhook or select Deploy to Production on the earlier commit or tag.
  • If a widely used PDT fails in production and you can't fix the SQL immediately, revert the PDT definition to the last known-good version. After the reverted PDT builds, Looker runs the dependent queries that were waiting for it.

What's next