ShareWatch is a Streamlit-based application installed on consumers of data share's Snowflake accounts to detect schema drifts in data shares received by these consumers. ShareWatch triggers notifications based on schema drift detection, which is part of Snowflake's best practices to operationalize shares, and integrates them in mission-critical data pipelines. The app provides a starting point and can be extended to implemenet other best practices discussed in the whitepaper.

Schema drift occurs where the structure (schema) of shared data is changed over time by the data provider. ShareWatch detects schema drifts by comparing the expected schema of each share to its current schema, and displaying the state of each share monitored in the app. ShareWatch also sets up a master task that runs all monitors on a schedule and sends email notifications if:

  1. Share is in "Warning" State: schema is appended i.e. new schema, object, or attribute is added to the schema.
  2. Share is in "Outage" State: schema is altered i.e. An alter, rename, delete, or revoke command on a schema, object, or attribute is performed

alt text

ShareWatch will also tell you which schemas, objects, or attributes are affected so you have a targeted area to explore and make the appropriate fixes in your pipelines. ShareWatch's "Accept Drift" feature allows you to accept changes in a share's schema and make it the new "expected" schema.

See below diagram for details on how ShareWatch detects schema drift

alt text

Key Features

Share Watch has 2 sections

  1. Configuration section - Set up schema drift monitoring on databases mounted from shares, set up an email recepient for notifications, and set up frequency at which ShareWatch's task should check for schema drift.
  2. Monitoring section - Shows the status of schema drift on databases mounted from shares based on the monitors set up in the Configuration section.

Prerequisites

What You'll Learn

What You'll Need

What You'll Build

alt text

What Triggers Alerts

ShareWatch's monitors are run from two places: either from task based on the schedule you set up or manually from "Manually Run Monitors" button at the top right of the Monitoring section.

When a monitor runs, it will check the expected schema of each share against the current schema of the share. If no changes are found, it will log in the share's history that it was checked at this time and skip to the next one.

If it does find drift within the share's schema, it will trigger one of two warning depending on the type of drift:

  1. Share is in "Warning" State: schema is appended i.e. new schema, object, or attribute is added to the schema.

alt text

  1. Share is in "Outage" State: schema is altered i.e. An alter, rename, delete, or revoke command on a schema, object, or attribute is performed

alt text

ShareWatch will also tell you which schemas, objects, or attributes are affected so you have a targeted area to explore and make the appropriate fixes in your pipelines.

Share Monitor History

At the bottom of the Monitoring section, you can choose a check a share monitor to check its history, which includes:

This history exists in the ShareWatch database and can be accessed from there for any workflows/analytics you'd like to build on top of ShareWatch.

alt text

Remediation

Once a schema has drifted work with the provider to understand the nature of the drift. Once provider due dilligence is done, you can use the "Accept Drifted State" button to accept the new schema of the shared dataset. This button will temporarily remove and re-add the monitor again, essentially resetting its expected state to the new schema structure.

alt text

Changing Task Schedule

ShareWatch will initially create the task in a suspended state as part of the Initial Configuration stage, assuming you want to start your schedule from the moment you initiate this configuration.

Here, you can change that task's schedule and it will start that schedule from the moment you changed this configuration as well.

You can always check the current configuration of the task using: describe task sharewatch.util.master_task;

Removing Share Monitors

This will show you the current shares you already have monitors for. If you want to remove any of them to reduce the number of shares checked every cadence of the task, you can do it from here. This will keep the history of that share if it gets added again.

Adding Share Monitors

This will show you the current databases based on shares you have in your environment. You can pick any of these shares to add a monitor for, and this share monitor will then be included in any future runs of the master task checking for schema drift in this share's database. If this share was added before as a monitor and then removed, you will also be able to see the history of that share under the Share History section.

alt text

Congratulations! You've successfully installed and configured sharewatch app to monitor schema drifts in your incoming shares.

What You Learned

Related Resources