Connect Snowflake for Warehouse-Native Experiment Analysis

This product is not supported for your selected Datadog site. ().

Overview

Warehouse-native experiment analysis lets you run statistical computations directly in your data warehouse.

To set this up for Snowflake, connect a Snowflake service account to Datadog and configure your experiment settings. This guide covers:

Step 1: Prepare the Snowflake service account

The examples in this guide use datadog_experiments_user and datadog_experiments_role as the service account’s user and role. Replace these with your own values.

Create a dedicated service user and role in Snowflake

  1. Use the Snowflake documentation to create a public-private key pair for enhanced authentication. Datadog only supports unencrypted private keys.
  2. Run the following commands in Snowflake to create the user and role in the service account. Replace <public_key> with the public key you generated in the previous step.
USE ROLE ACCOUNTADMIN;
CREATE ROLE IF NOT EXISTS datadog_experiments_role;
CREATE USER IF NOT EXISTS datadog_experiments_user
    RSA_PUBLIC_KEY = '<public_key>';
GRANT ROLE datadog_experiments_role TO USER datadog_experiments_user;
ALTER USER datadog_experiments_user SET DEFAULT_ROLE = datadog_experiments_role;

Grant privileges to the role

  1. Identify the tables in Snowflake from which you intend to create metrics.
  2. Run the following commands to grant read privileges to the new role, replacing <database>, <schema>, and <table> with their appropriate values. Run both GRANT USAGE commands, then run the GRANT SELECT option or options that match your access needs.
GRANT USAGE ON DATABASE <database> TO ROLE datadog_experiments_role;
GRANT USAGE ON SCHEMA <database>.<schema> TO ROLE datadog_experiments_role;

-- Option 1: Give read access to a single table
GRANT SELECT ON TABLE <database>.<schema>.<table> TO ROLE datadog_experiments_role;

-- Option 2: Give read access to all existing tables in the schema
GRANT SELECT ON ALL TABLES IN SCHEMA <database>.<schema> TO ROLE datadog_experiments_role;

-- Option 3: Give read access to all future tables in the schema
GRANT SELECT ON FUTURE TABLES IN SCHEMA <database>.<schema> TO ROLE datadog_experiments_role;

Grant the role access to the output schema

Datadog writes experiment exposure logs and intermediate metric results to tables in a dedicated output schema. Run the following commands to create the schema and grant the role full access. Replace <database> with the appropriate value.

CREATE SCHEMA IF NOT EXISTS <database>.datadog_experiments_output;
GRANT ALL ON SCHEMA <database>.datadog_experiments_output TO ROLE datadog_experiments_role;
GRANT ALL PRIVILEGES ON FUTURE TABLES IN SCHEMA <database>.datadog_experiments_output TO ROLE datadog_experiments_role;

Create a dedicated warehouse for Datadog Experiments (optional)

The role you created must have access to at least one warehouse to compute results. You must enter the warehouse name when configuring experiment settings in Step 3.

Creating a dedicated warehouse for Datadog Experiments is optional. Run the following commands to create one. Replace <wh_size> with the appropriate value.

CREATE WAREHOUSE IF NOT EXISTS datadog_experiments_wh
    WAREHOUSE_SIZE = <wh_size>
    AUTO_SUSPEND = 300
    INITIALLY_SUSPENDED = true;
GRANT ALL PRIVILEGES ON WAREHOUSE datadog_experiments_wh TO ROLE datadog_experiments_role;

Step 2: Connect Snowflake to Datadog

To connect your Snowflake account to Datadog for warehouse-native experiment analysis:

  1. Navigate to Datadog’s integrations page and search for Snowflake.
  2. Click the Snowflake tile to open its modal.
  3. Select the Configure tab and click Add Snowflake Account.
  4. Add your Account URL. To find your account URL, see the Snowflake guide.
  5. Toggle off all resources (these are not needed for experiment analysis).
  6. Enter the Snowflake User Name you created in Step 1 (for example, datadog_experiments_user).
  7. Scroll to the Configure a key pair authentication section and upload your unencrypted private key.
  8. Click Save.
The grants in the Recommended Warehouse Settings section of the Snowflake integration tile are not needed for warehouse-native experiment analysis. The privileges granted in Step 1 are sufficient.

If you plan to use other warehouse observability functionality in Datadog, see Datadog's Snowflake integration documentation to determine which resources to enable.
The Snowflake integration tile in Datadog showing the Configure tab with the Add a new Snowflake account form, including an Account URL field and resource toggles for Metrics and Logs.

Step 3: Configure experiment settings

After you set up your Snowflake integration, configure the experiment settings in Datadog Product Analytics:

  1. In the left navigation, hover over Settings, then click Experiments.
  2. Select the Warehouse Connections tab.
  3. Click Connect a data warehouse. If you already have a warehouse connected, click Edit instead.
  4. Select the Snowflake tile.
  5. Enter the Account, Role, Warehouse, Database, and Schema you configured in Step 1. If your database and schema do not appear in the dropdown, enter them manually to add them to the list.
  6. Click Save.
The Edit Data Warehouse modal with Snowflake selected, showing two sections: Select Snowflake Account with fields for Account, Role, and Warehouse, and Select Database and Schema with fields for Database and Schema.

After you save your warehouse connection, create experiment metrics using your Snowflake data. See Create Experiment Metrics.

Further reading