Prerequisites
To create a metric data source in the LaunchDarkly UI:- You must have an existing warehouse native Experimentation integration. To learn more, read Setting up external warehouses.
Snowflake-specific prerequisites
If you are using Snowflake, you must have theLD_DATA_SOURCE_ROLE role in Snowflake. You create this role when you set up the Snowflake Native Experimentation integration. If you modify the native-app-provided SQL before you run it, be sure that this role has read-only access to your metric events tables, schemas, and databases, and no other resources.
When LaunchDarkly calculates your experiment results, it will execute your data source query using the role LD_EXPERIMENTATION_ROLE.
Create data sources
When you create a new metric data source from your warehouse tables, you must map your warehouse table columns to the schema that LaunchDarkly needs to create a metric and run an experiment. To create a data source:- Open the Data section and navigate to the Data sources list.
- Click Create metric source.
- Enter a data source Name in the “Name your data source” section.
- (Optional) Add a Description.
- Click Select warehouse integration in the “Define data source” section and choose the integration for a specific LaunchDarkly project and environment.
- Choose an option from the “Select input method” section to select tables to include in the data source:
- To use a single table or view, click Table and enter the fully-qualified name of the table or view that provides all metric events. For example,
database.schema.view-or-table. - To use multiple tables or views, click Query and enter a SQL query against all tables or views that provide metric events you want to include. The query must return data from all columns that provide required ID types to LaunchDarkly. These include a timestamp, an event key such as
purchaseorbutton click, an event value (can benull), and at least one column identifying the event’s context, such asuser_idordevice_id.
- To use a single table or view, click Table and enter the fully-qualified name of the table or view that provides all metric events. For example,
- Click Run query to retrieve column names from the table or SQL statement you provided.
- Map your warehouse table columns to fields in LaunchDarkly in the “Map your data in LaunchDarkly” section:
- Timestamp: Map to the timestamp when the event occurred. Choose a column that uses the timestamp or datetime format and encodes timezone information, to ensure that metric events are attributed correctly relative to experiment context exposures.
- Context key: Map to one of your context kinds defined in LaunchDarkly. For example, you can map a “user_id” column to the LaunchDarkly “user” context.
- (Optional) Click Add another context pair to add another key/kind pair. For Snowflake data sources, you can use additional mapped columns for filtering custom events when you create metrics from this data source. To learn more, read Filtering custom metric events.
- Event value: (Optional) Map to a numeric value representing the event’s measurement, such as
order_amount, or1for conversion events. Select None to leave the column unmapped and choose the value column each time you create a numeric metric from this data source. To learn more, read Event value mapping. - Event key: Map to the key of the event type, such as
purchase,add to cart, orpage view.
- Click Save configuration.
Event value mapping
Mapping an Event value column in a data source is optional. Numeric metrics that use sum or average aggregation require a value column, which can come from the data source or from the metric itself:- If you map an Event value column in the data source, numeric metrics you create from the data source use that column by default. When you create a metric, you can select a different column in the Numeric value column field to override the mapping for that metric only. Metrics that keep the default continue to follow the data source mapping if you change it later.
- If you select None for Event value, you must choose the column that provides the value each time you create a numeric metric from the data source.
Edit data source configurations
To edit an existing data source:- Open the Data section and navigate to the Data sources list.
- Click the three-dot overflow menu for the data source you want to archive.
- Select Edit configuration. The “Configuration” tab opens.
- Make any changes as needed and click Save configuration.
Archive data sources
You can archive a data source when you no longer need it. Archiving a metric data source does not make changes to the warehouse integration it is linked to. To archive a data source:- Open the Data section and navigate to the Data sources list.
- Click the three-dot overflow menu for the data source you want to archive.
- Select Archive.