Overwatch

repository·main·Indexed 42 days ago

https://github.com/databrickslabs/overwatch

A deprecated telemetry unification tool for Databricks and Spark deployments designed to provide governance and actionable intelligence. It enables the retrieval of platform data—including jobs, clusters, and SQL history—as Spark DataFrames and provides utilities for persisting this data into Delta tables with support for parallel API calls and automated merge operations.

Tokens
8.8K
Snippets
32
Records
43
Agent score
53%

What's inside Overwatch

  1. Overview of Overwatch

    main
    Overwatch is a tool designed to unify Spark and Databricks Platform telemetry. Its purpose is to provide calibrated precision for the Databricks Unified Analytics Platform, enabling governance and actionable intelligence by helping users gain key insights into their Databricks deployments.
  2. Configure the environment for Overwatch development

    main

    To ensure compatibility with the project, your development environment must match the dependencies used by Databricks runtime 10.4 LTS. Ensure you have the following versions installed:

    • Java: Zulu 8.56.0.21
    • Scala: 2.12.14
    • SBT: 1.2.8
  3. Install and configure SBT

    main

    SBT (Scala Build Tool) can be installed in two ways:

    1. System-wide: Install SBT directly on your operating system and use it via the terminal.
    2. IDE Integration: Install the SBT plugin within an IDE like IntelliJ IDEA.

    Critical Requirement: Regardless of the installation method, ensure that your SBT installation is explicitly pointing to the correct Java installation (Zulu 8.56.0.21) to avoid build failures.

  4. Supported configuration formats for Migration

    main

    The Migration class supports three distinct types of configuration storage. The logic used to update the storage_prefix is determined by the format of the configPath provided:

    FormatDetection LogicUpdate Mechanism
    CSV FileEnds with .csvReads CSV, updates storage_prefix column where etl_database_name matches, and overwrites the file.
    Delta PathContains / (and not .csv)Executes a Spark SQL UPDATE statement on the Delta location: update delta.$configPath set storage_prefix = '$target_storage_prefix' WHERE etl_database_name = '$sourceETLDB'
    Delta TableNo / detectedExecutes a Spark SQL UPDATE statement on the table: update $configPath set storage_prefix = '$target_storage_prefix' WHERE etl_database_name = '$sourceETLDB'
  5. How PostProcessor handles intermediate targets

    main

    When optimizing certain primary targets, PostProcessor automatically includes related intermediate tables to ensure data consistency and prevent orphaned data. This prevents forcing an optimize on every single pipeline run by tying intermediate tables to their leader tables.

    Specifically:

    • If audit_log_bronze is marked for optimization, the following are also included: processedEventLogs, clusterEventsErrorsTarget, pipelineStateTarget, cloudMachineDetail, and dbuCostDetail.
    • If spark_events_bronze is marked, processedEventLogs is also included.

    Optimization parameters for spark_events_bronze are specialized: it uses a smaller maxFileSizeMB = 32, while other tables use maxFileSizeMB = 128.

  6. Support and Issue Reporting for Overwatch

    main

    Overwatch is provided AS-IS and is not formally supported by Databricks with Service Level Agreements (SLAs).

    • Do not submit Databricks support tickets for issues arising from this project.
    • Report issues via GitHub Issues on the repository. These will be reviewed as time permits, but there are no formal SLAs for support.
  7. Enable destructive database operations

    main

    To protect against accidental data loss, Overwatch requires an explicit Spark configuration to be set before running destructive commands (like fastDropTargets).

    You must set the Spark configuration overwatch.permit.db.destruction to a value exactly matching the name of the target database you intend to modify.

    If this configuration is missing or incorrect, a com.databricks.labs.overwatch.utils.BadConfigException will be thrown.

    -- Example: If your target database is 'my_prod_db'
    SET overwatch.permit.db.destruction = my_prod_db;
  8. Configure API call behavior via ApiEnv

    main

    The ApiEnv object (passed to ApiCallV2) controls the core authentication and connection settings:

    • workspaceURL: The base URL of the Databricks workspace.
    • rawToken: The PAT token used for Bearer authentication.
    • packageVersion: Used in the User-Agent header.
    • successBatchSize: The number of responses to accumulate before writing a micro-batch to the successTempPath (if batchPersist is enabled).
    • errorBatchSize: The number of errors to accumulate before writing to the error path.
    • threadPoolSize: The number of threads used during parallel API calls.
    • apiWaitingTime: The timeout threshold for waiting for parallel calls to complete.
  9. Configure Table Lock Timeout

    main

    In multi-workspace deployments where target.requiresLocking is true, Overwatch uses a global table lock to prevent race conditions during parallel writes. If a table is locked, the process will wait until the lock is released or the timeout is reached.

    You can control this timeout by setting the following Spark configuration on your cluster:

    overwatch.tableLockTimeout (milliseconds)

    • Default: 1200000 (20 minutes).
    • Usage: Increase this value for historical loads or large-scale data migrations to prevent TABLE LOCK TIMEOUT errors.
    spark.conf.set("overwatch.tableLockTimeout", "3600000") // Set to 1 hour
  10. Migrate ETL Database to a new target using Migration.process

    main

    The Migration.process method automates the migration of an Overwatch ETL database and its associated consumer database to a new target location. It performs a deep snapshot of the source, updates the configuration files (CSV, Delta path, or Delta table) with the new storage prefix, and then drops the original source and consumer databases.

    Workflow:

    1. Validation: Checks if the source is a valid Overwatch database and if the configuration path is accessible and consistent.
    2. Snapshot: Performs a DEEP clone of the source ETL database to the migrateRootPath.
    3. Config Update: Updates the storage_prefix in the configuration to match the new target path for the specific sourceETLDB.
    4. Cleanup: Drops both the source ETL database and the consumer database using CASCADE.

    Parameters:

    • sourceETLDB: The name of the source ETL database.
    • migrateRootPath: The target path where the migration will be performed.
    • configPath: The path to the configuration file (supports .csv files, Delta paths, or Delta table names).
    • tablesToExclude: (Optional) A string representing table names to exclude from the migration. Defaults to an empty string.
    // Example usage of the Migration process
    Migration.process(
      sourceETLDB = "my_source_etl_db",
      migrateRootPath = "/mnt/target/path/",
      configPath = "/mnt/configs/overwatch_config.csv",
      tablesToExclude = "table1,table2"
    )