Decube
Try for free
  • 🚀Overview
    • Welcome to decube
    • Getting started
      • How to connect data sources
    • Changelog
    • Public Roadmap
  • 💻Security & Infrastructure
    • Overview
    • Deployment Methods
      • SaaS (Multi-Tenant)
      • SaaS (Single-Tenant)
      • Bring-Your-Own-Cloud (BYOC)
    • Data Policy
  • 🔌Data Warehouses
    • Snowflake
    • Redshift
    • Google Bigquery
    • Databricks
    • Azure Synapse
  • 🔌Relational Databases
    • PostgreSQL
    • MySQL
    • SingleStore
    • Microsoft SQL Server
    • Oracle
  • 🔌Transformation Tools
    • dbt (Cloud Version)
    • dbt Core
    • Fivetran
    • Airflow
    • AWS Glue
    • Azure Data Factory
    • Apache Spark
      • Apache Spark in Azure Synapse
    • OpenLineage (BETA)
    • Additional configurations
  • 🔌Business Intelligence
    • Tableau
    • Looker
    • PowerBI
  • 🔌Data Lake
    • AWS S3
    • Azure Data Lake Storage (ADLS)
      • Azure Function for Metadata
    • Google Cloud Storage (GCS)
  • 🔌Ticketing and Collaboration
    • ServiceNow
    • Jira
  • 🔒Security and Connectivity
    • Enabling VPC Access
    • IP Whitelisting
    • SSH Tunneling
    • AWS Identities
  • ✅Data Quality
    • Incidents Overview
    • Incident model feedback
    • Enable asset monitoring
    • Available Monitor Types
    • Available Monitor Modes
    • Catalog: Add/Modify Monitor
    • Set Up Freshness & Volume Monitors
    • Set Up Field Health Monitors
    • Set Up Custom SQL Monitors
    • Grouped-by Monitors
    • Modify Schema Drift Monitors
    • Modify Job Failure Monitors (Data Job)
    • Custom Scheduling For Monitors
    • Config Settings
  • 📖Catalog
    • Overview of Asset Types
    • Assets Catalog
    • Asset Overview
    • Automated Lineage
      • Lineage Relationship
      • Supported Data Sources and Lineage Types
    • Add lineage relationships manually
    • Add tags and classifications to fields
    • Field Statistcs
    • Preview sample data
  • 📚Glossary
    • Glossary, Category and Terms
    • Adding a new glossary
    • Adding Terms and Linked Assets
  • Moving Terms to Glossary/Category
  • AI Copilot
    • Copilot's Autocomplete
  • 🤝Collaboration
    • Ask Questions
    • Rate an asset
  • 🌐Data Mesh [BETA]
    • Overview on Data Mesh [BETA]
    • Creating and Managing Domains/Sub-domains
    • Adding members to Domain/Sub-domain
    • Linking Entities to Domains/Sub-domains
    • Adding Data Products to Domains/Subdomains
    • Creating a draft Data Asset
    • Adding a Data Contract - Default Settings
    • Adding a Data Contract - Freshness Test
    • Adding a Data Contract - Column Tests
    • Publishing the Data Asset
  • 🏛️Governance
    • Governance module
    • Classification Policies
    • Auto-classify data assets
  • ☑️Approval Workflow
    • What are Change Requests?
    • Initiate a change request
    • What are Access Requests?
    • Initiate an Access Request
  • 📋Reports
    • Overview of Reports
    • Supported sources for Reports
    • Asset Report: Data Quality Scorecard
  • 📊Dashboard
    • Dashboard Overview
    • Incidents
    • Quality
  • ⏰Alert Notifications
    • Get alerts on email
    • Connect your Slack channels
    • Connect to Microsoft Teams
    • Webhooks integration
  • 🏛️Manage Access
    • User Management - Overview
    • Invite users
    • Deactivate or re-activate users
    • Revoke a user invite
  • 🔐Group-based Access Controls
    • Groups Management - Overview
    • Create Groups & Assign Policies
    • Source-based Policies
    • Administrative-based Policies
    • Module-based Policies
    • What is the "Owners" group?
  • 🗄️Org Settings
    • Multi-factor authentication
    • Single Sign-On (SSO) with Microsoft
    • Single Sign-On (SSO) with JumpCloud
  • Export/Import
    • Export/Import Overview
  • Export for Editing existing objects
  • Export for Creating new objects
  • CSV Template Structure (Edit existing items)
  • CSV Template Structure (Add new items)
  • Importing Data (Edit existing items & Add new items)
  • History
  • ❓Support
    • Supported Features by Integration
    • Frequently Asked Questions
    • Supported Browsers and System Requirements
  • Public API (BETA)
    • Overview
      • Data API
        • Glossary
        • Lineage
        • ACL
          • Group
      • Control API
        • Users
    • API Keys
Powered by GitBook
On this page
  • Step 1: Set-up
  • Step 2: Configure: Schedule Monitor
  • Get Notified/Custom Alert
  • Configure: On-demand Monitor
  • Tips and Tricks
  • Label invalidation
  • Value Sum
  • Discrepancy
  1. Data Quality

Set Up Custom SQL Monitors

Write your own SQL scripts to set up tests specific to your needs.

PreviousSet Up Field Health MonitorsNextGrouped-by Monitors

Last updated 3 months ago

Custom SQL Monitor provides and easy and flexible interface for monitoring the database based on custom SQL filter. This feature takes in the select query provided by the user and wraps it in a subquery which does a row_count on the result and record incident if row_count > 0.

You can choose either to set up a or one that has a column selected as a segmentation.

How to Set Up a Custom SQL Monitor

  • Select the “Custom SQL” card from the Config module.

  • You’ll be directed to the “Create a New Monitor” form with Setup and Configure steps.

The form fields will become available as you select the mandatory options.

Step 1: Set-up

  • Select a Data Source.

  • Choose Monitor Mode (Scheduled or On-Demand).

  • If applicable you can set your monitor as Grouped by, you can turn on the toggle

  • Click “Proceed to Monitor Setup” to continue.

Step 2: Configure: Schedule Monitor

  • Once you proceed to setup, you’ll reach the “Configure” page, where you can review your previous selections.

Within the "Configure" popup, users must complete the necessary fields to save their preferences and successfully set up their Custom SQL monitor. These required fields include:

  • Can create multiple tests for each test type per column/table

  • Able to add a test name to differentiate monitors created

  • Monitor Name

  • Monitor Description is Optional.

  • Frequency

  • Add your Custom SQL query: Enter the query and Click on Validate, Once query is validated success message (Query successfully validated) will be displayed.

Note that if you modify the query after validating it, you will need to re-validate the query again.

Get Notified/Custom Alert

  • To set custom alerts, you must first turn on the "Notify default channel" toggle. Activating this will allow users to specify their desired alert channels, be it via emails or Slack channels.

    • You can select the desired alert channels in the dropdown.

    • Mention the address or channel name in the field.

  • At last select the Incident Levels

  • Click on Submit and your monitor is created successfully.

  • Once you click on Submit you’ll be redirected to All Monitor tab.

Configure: On-demand Monitor

  • Set-up

  • Select the data source and Monitor Mode

  • If applicable you can set your monitor as Grouped by, by turning on the toggle

  • Once you click on Proceed to monitor setup ,you will reach the next page (Configure).

  • Here, on the top you can see the previous page selection overview.

Within the "Configure" popup, users must complete the necessary fields to save their preferences and successfully set up their Custom SQL monitor. These required fields include:

  • Can create multiple tests for each test type per column/table

  • Able to add a test name to differentiate monitors created

  • Monitor Name

  • Monitor Description is Optional.

  • Add your Custom SQL query: Enter the query and Click on Validate, Once query is validated success message (Query successfully validated) will be displayed.

Custom Notifications: On the Configure Monitoring pop up for both On Demand and Scheduled monitors, can also toggle the notification settings as well as custom alerts for each monitor modes.

  • Upon completing the required fields to create an On Demand monitor for Custom SQL, users can complete the set up process by choosing either of the following confirmation buttons based on their preferred use case:

    • Save: This is an applicable option for users who wish to set up an on demand monitor without running the monitor scan immediately after creation.

    • Save an run : This option is applicable for users who wish to run the On Demand Monitor immediately upon creation. For the next time users wish to run the on demand monitor again, users can navigate to the All Monitor's.

    • After selecting the above option you will be redirected to ALL MONITORS tab.

  • Modify Monitoring

To modify an existing monitor:

  1. Go to All Monitors.

  2. Click the ellipsis (︙) and select View Monitor.

  3. Click on Run once to run the monitor manually.

Tips and Tricks

In this section, we will show a few ways you can configure the monitor using the power of SQL!

Label invalidation

Filtering records with specified label to trigger an incident

SELECT *
FROM public.sale
WHERE created_at BETWEEN 
	NOW() - '30mins'::INTERVAL AND NOW()
    AND status in ('pending', 'rejected')

Value Sum

Filtering sum of value over a threshold of a specified interval

SELECT 1
FROM public.sale
WHERE created_at BETWEEN 
	NOW() - '30mins'::INTERVAL AND NOW()
HAVING SUM(price * quantity) > 10000

Discrepancy

The discrepancy between 2 tables

WITH sale AS (
    SELECT SUM(price * quantity) as amount
    FROM public.sale
    WHERE created_at BETWEEN 
        NOW() - '30mins'::INTERVAL AND NOW()
)
, in_flow AS (
    SELECT SUM(amount) as amount
    FROM public.in_flow
    WHERE created_at BETWEEN 
        NOW() - '30mins'::INTERVAL AND NOW()
)
, base AS (
    SELECT 
        (SELECT amount FROM sale) 
        - (SELECT amount FROM in_flow) 
    AS discrepancy
) 
SELECT discrepancy 
FROM   base 
WHERE  discrepancy >  10000

To set your monitor as grouped by you can refer to documentation.

For setting up On-demand Monitor/Schedule Grouped By you can refer to

✅
Grouped-By
Get Notified/Custom Alert
Configure: On-demand /Schedule Monitor Grouped By for Custom SQL
Normal Custom SQL monitor
Group-by
Selection for Custom SQL card
Grouped-by diabled
Grouped-by enabled
Overview from previous selection
Overview for Custom SQL Query
Setting-up custom alert/notification
Set-up On demand monitor
Selection from previous page
Overview for SQL Query validation