Get icon
Script icon
Docker icon
Set icon
If icon
SlackIncomingWebhook icon
Fail icon
Log icon
Webhook icon
Schedule icon

dbt Core Semantic Layer Metric Drift & Semantic Manifest Gate

Detect breaking changes in dbt semantic manifests and block deployment on warehouse metric drift. Orchestrate data quality gates with Kestra.

Categories
CoreData

Automate semantic contract governance for dbt Core and MetricFlow by validating candidate semantic_manifest.json artifacts against certified production baselines. Detect breaking mutations in metrics, dimensions, measures, and entities, execute warehouse verification queries to measure numerical KPI drift, and gate CI/CD deployments before bad metrics break executive dashboards.

How it works

  1. Baseline Ingestion: The load_baseline_manifest task reads the certified production semantic manifest from the Kestra KV store (dbt_semantic_manifest_prod) with automatic fallback to initial certified schemas.
  2. Semantic Diff Inspection: The analyze_semantic_manifest_diff task runs an isolated Python Docker container to compare candidate and baseline manifests. It flags removed metrics, modified calculation types, altered entity joins, mutated measure aggregations (such as sum to average), and deleted grain dimensions.
  3. Warehouse KPI Verification: The Python audit task executes verification SQL queries against in-memory DuckDB warehouse tables representing key business metrics (revenue, active users, order volume) to detect numerical calculation drift against defined percentage thresholds.
  4. Telemetry Persistence: The persist_audit_report task writes the complete structured audit manifest into Kestra KV (dbt_semantic_layer_audit_report) for historical observability.
  5. Quality Gating: If breaking changes or KPI drift exceed thresholds, evaluate_semantic_gate alerts the #analytics-engineering Slack channel and terminates the run with io.kestra.plugin.core.execution.Fail. Otherwise, it updates the production baseline in KV and approves the promotion.

What you get

  • Automated detection of breaking dbt semantic layer changes in CI/CD before deployment.
  • Protection against silent aggregation mutations (such as changing a measure from sum to average).
  • Granular warehouse verification comparing numerical KPI drift against SLA thresholds.
  • Complete audit trail persisted in Kestra KV store with structured JSON telemetry.
  • Instant Slack alerts with actionable violation summaries for analytics engineers.

Who it's for

  • Analytics Engineers maintaining dbt Core Semantic Layer or MetricFlow models.
  • Data Platform Teams implementing automated CI/CD guardrails and deployment gates.
  • BI Engineers protecting downstream dashboards in Superset, Tableau, or Hex from semantic outages.

Why orchestrate this with Kestra

  • Containerized Auditing: Executes complex semantic graph parsing and DuckDB verification queries in isolated Docker containers without host dependencies.
  • Native KV State Management: Stores certified baseline manifests and audit telemetry directly in Kestra KV store without external databases.
  • Declarative Quality Gating: Combines native io.kestra.plugin.core.flow.If and io.kestra.plugin.core.execution.Fail tasks for deterministic pipeline control.
  • Multi-Trigger Support: Operates as an automated webhook gate for CI/CD runners or as a scheduled recurring weekly audit.

Prerequisites

  • Docker daemon accessible to Kestra workers.
  • Slack Incoming Webhook URL configured in Kestra secrets.
  • Webhook authentication key configured for CI/CD invocation.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL for analytics team alerts.
  • DBT_GATE_WEBHOOK_KEY: Secret authentication key for the inbound webhook trigger.

Quick start

  1. Store your Slack webhook URL in Kestra secrets under SLACK_WEBHOOK_URL.
  2. Store your webhook authentication key under DBT_GATE_WEBHOOK_KEY.
  3. Run a manual execution with fault_injection_mode: NONE to verify the nominal pass path and populate the initial KV baseline.
  4. Execute a test run with fault_injection_mode: MUTATE_AGGREGATION_SUM_TO_AVG to verify that breaking measure aggregations are caught and gated.

How to extend

  • Warehouse Connection: Replace the in-memory DuckDB warehouse verification queries with native Snowflake (io.kestra.plugin.jdbc.snowflake.Query), BigQuery (io.kestra.plugin.gcp.bigquery.Query), or PostgreSQL (io.kestra.plugin.jdbc.postgresql.Query) tasks.
  • S3 / GCS Artifact Storage: Store historical semantic manifests in cloud object storage using io.kestra.plugin.aws.s3.Upload or io.kestra.plugin.gcp.gcs.Upload.
  • Human Approval Pause: Add an io.kestra.plugin.core.flow.Pause task allowing lead data stewards to manually approve minor metric drift before failing.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.