# Cortex Framework observability

Google Cloud Cortex Framework provides operational visibility across both phases of
your data pipeline lifecycle:

- **[Deploy-time observability](https://docs.cloud.google.com/cortex/docs/observability.md.txt#deploy-time-observability)**: Tracks configuration validation, schema and DDIC discovery, assertion SQL compilation, and target synchronization when running CLI tools.
- **[Run-time observability](https://docs.cloud.google.com/cortex/docs/observability.md.txt#run-time-observability)** : Tracks Dataform workflow executions, BigQuery job performance, severity-tagged [data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt), and automated alerting in Google Cloud.

## Deploy-time observability

Deploy-time observability covers local and CI/CD runs of `uv run cortex-build`,
`uv run cortex-compile`, `uv run cortex-deploy`,
`uv run cortex-build-and-deploy`, `uv run cortex-apply-security`,
`uv run cortex-demo`, `uv run cortex-metadata`,
`uv run cortex-create-kc-data-products`, `uv run cortex-create-ca-agents`, and
`uv run cortex-register-gemini-agents`.

### Local console logging

CLI tools stream structured progress messages and the temporary log-file path
notice to `stdout` by default, while machine-readable output modes such as
`uv run cortex-compile --json` redirect logs to `stderr` so `stdout` contains
clean JSON:

- **Structured log output** : `setup_logging` logs `INFO`-level progress messages with formatted timestamps and severity labels---along with `WARNING`, `ERROR`, and full exception tracebacks---to both the active console stream (`stdout` by default, or `stderr` in JSON mode) and the temporary log file.
- **Status indicators** : Highlights critical failures that stop execution (`ERROR`) separately from nonfatal configuration or optional DDIC warnings (`WARNING`).
- **Credential redaction** : Automatically masks embedded Git tokens and credentials (`***`) in console and file logs during `type: git` deployments.

### Persistent local log files

Every CLI invocation writes complete diagnostic output (including full stack
traces) to a timestamped log file in your operating system's temporary directory
(`/tmp` on Linux, `%TEMP%` on Windows, or `$TMPDIR` on macOS):

    <temp_dir>/cortex-framework-logs-<YYYYMMDD-HHMM>.log

The exact path prints at CLI startup so you can archive it as a CI/CD build
artifact or attach it to support tickets.

### Environment and assertion validation

Before executing build, deploy, or catalog sync operations,
Cortex Framework runs pre-flight checks:

- **Build-input checks (`cortex-build` and `cortex-build-and-deploy`)** : Verifies that required source APIs (`bigquery.googleapis.com`, plus `analyticshub.googleapis.com` or `biglake.googleapis.com` for enabled external catalogs) are active, raw source datasets exist and match `data.bigQueryLocation`, and enabled BigQuery sharing linked datasets exist, aren't `UNLINKED`, and match `data.bigQueryLocation` (logging warnings for `STALE` or `INACTIVE` subscriptions or non-linked dataset copies).
- **Deployment-target checks (`cortex-deploy` and `cortex-build-and-deploy`)** : For enabled `type: dataform` targets, Cortex Framework verifies `dataform.googleapis.com` and target BigQuery APIs, validates or creates target datasets (including `data.defaultAssertionDataset` when `data.assertionsEnabled` is `true`) in `data.bigQueryLocation`, and checks `ENTERPRISE_PLUS` query reservations when BigLake Delta Sharing catalogs are enabled. When `data.security.enabled: true` is configured with column policy tags, both `type: dataform` deployment pre-flight checks and [`uv run cortex-apply-security`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-apply-security.md.txt) verify `datacatalog.googleapis.com` and confirm that referenced policy tags exist in `data.bigQueryLocation` with **Enforce access control** enabled. Dataform deployments also log a `WARNING` if an existing table's partitioning differs from `partitionDetails`. When all enabled targets use `type: git`, Google Cloud API and target dataset checks are skipped.
- **Automatic assertion validation and local compilation** : `uv run cortex-build` automatically validates assertion schemas, rule parameters, and custom SQL templates during workspace generation. Running [`uv run cortex-compile`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-compile.md.txt) compiles the generated Dataform project locally (strictly offline when passed `--dist-dir`) to verify that all modules and assertion definitions resolve and compile cleanly before deployment.

### Telemetry

When interacting with Google Cloud projects, deployment and sync tools
record anonymous framework version and module adoption telemetry. For details
and opt-out instructions (`--disable-telemetry`), see
[Telemetry](https://docs.cloud.google.com/cortex/docs/telemetry.md.txt).

## Run-time observability

Once deployed, conformed foundations, data products, and assertions execute
inside **Dataform** and **BigQuery**, integrating directly
with Cloud Logging and Cloud Monitoring.

### Pipeline execution logging

- **Dataform workflow logs** : Every compilation result and workflow invocation is recorded in [Logging](https://docs.cloud.google.com/logging/docs.md.txt) and accessible through the Google Cloud console or the [Dataform API](https://docs.cloud.google.com/dataform/reference/rest.md.txt).
- **BigQuery job history** : Each table refresh, incremental CDC merge, and assertion check runs as a BigQuery SQL job exposing slot consumption, bytes billed, and error diagnostics in [BigQuery job history](https://docs.cloud.google.com/bigquery/docs/managing-jobs.md.txt#view_job_details).
- **Standardized BigQuery resource labels** : Deployed tables and views receive standardized labels (`module_category`, `module_type`, `namespaced_module_type`, and `module_id`) that you can use for job, cost, and resource monitoring across modules.

### Pipeline monitoring

1. Open [Dataform in the Google Cloud console](https://console.cloud.google.com/bigquery/dataform) to inspect compiled DAG dependencies, release configurations, and workflow execution history.
2. Use [Monitoring](https://docs.cloud.google.com/monitoring/docs.md.txt) dashboards to track workflow execution duration, compilation errors, and failed action counts.

### Alerting and data quality assertions

Cortex Framework compiles declarative
[data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt) configured in
`table_settings.yaml` into Dataform assertion views inside
`data.defaultAssertionDataset` (default `dataform_assertions`), named
`<moduleId>_<tableName>_assert_<ruleName>`:

- **Blocking versus non-blocking execution** :
  - Rules with `blocking: false` (the default) execute in parallel with downstream models. If a rule returns violating rows, Dataform marks the assertion action as failed in Logging without halting downstream tables.
  - Rules with `blocking: true` register as upstream dependencies of downstream models published using `publisher.publish()` or `publisher.operate()` (and inject an in-transaction procedural check into SAP foundation scripts that issues `ROLLBACK TRANSACTION` on failure for both incremental CDC merges and subsequent full refreshes, or `DROP TABLE IF EXISTS` on initial table creation before raising an error), halting downstream refreshes immediately when bad data is detected.
- **Built-in and severity-based execution tags** : Every generated assertion automatically receives the `data_quality`, `assertion`, and either `blocking_assertion` (when `blocking: true`) or `non_blocking_audit` (when `blocking: false`) tags. Defining `data.assertionSeverities` and `data.defaultAssertionSeverity` in `config/config.yaml` also attaches a `severity_<value>` tag (for example, `severity_critical` or `severity_warn`) so you can schedule critical checks separately from informational audits.
- **Custom SQL assertion templates** : Validated during `uv run cortex-build`; for `templateFile` directory precedence and syntax, see [Data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt).
- **Triaging failed rows in BigQuery** : Query any failed
  assertion view directly in `dataform_assertions` to inspect the violating keys
  and columns:

  ```sql
  SELECT *
  FROM `TARGET_PROJECT_ID.dataform_assertions.ASSERTION_VIEW_NAME`
  LIMIT 100;
  ```

  Replace the following:
  - `TARGET_PROJECT_ID`: your target Google Cloud project ID, for example: `my-target-project`.
  - `ASSERTION_VIEW_NAME`: the compiled assertion action name, for example: `erp_bkpf_assert_unique_key_mandt_bukrs_belnr_gjahr`.

For rule syntax, partition-pruning `lookbackDays`, and SAP `tcurx` cross-layer
parity configuration, see
[Data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt).

### Cloud alerting policies

Configure [Monitoring alerting policies](https://docs.cloud.google.com/monitoring/alerts.md.txt) to notify
on-call teams when transformations or assertions fail:

- **[Log-based alerts](https://docs.cloud.google.com/logging/docs/alerting/log-based-alerts.md.txt)** : Trigger alerts in [Logging](https://docs.cloud.google.com/logging/docs.md.txt) on failed Dataform workflow invocations or assertion actions matching `_assert_`.
- **Metric-based alerts** : Set thresholds in [Monitoring](https://docs.cloud.google.com/monitoring/docs.md.txt) for workflow duration anomalies or failed job counts, routed to your [notification channels](https://docs.cloud.google.com/monitoring/support/notification-options.md.txt).

## What's next

- Configure validation rules and blueprints in [Data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt).
- Review support coverage and escalation steps in [Support overview](https://docs.cloud.google.com/cortex/docs/support-v7.md.txt).
- Manage telemetry settings in [Telemetry](https://docs.cloud.google.com/cortex/docs/telemetry.md.txt).