Contact us for help configuring ClickHouse native ExperimentationAccess to ClickHouse native Experimentation requires both Data Export and Experimentation. If you do not have access or need help getting started, contact your LaunchDarkly representative or start a Support ticket.
- Configure the LaunchDarkly integration
- Run the setup script in ClickHouse
- Test the connection and save the integration
- Verify the connection
Prerequisites
Before setting up ClickHouse native Experimentation, ensure that you have:- The ClickHouse Data Export integration set up in LaunchDarkly for the project and environment you use. Only environments with a ClickHouse Data Export destination are available when you create this integration.
- A LaunchDarkly role of Owner or Admin, or a custom role that allows the following actions:
- Access to the ClickHouse SQL console as a user who can create users and grant privileges.
- Metric event data in ClickHouse that you want to use for Experimentation.
- If your ClickHouse service restricts inbound connections by IP address, an IP access list that includes the following LaunchDarkly IP addresses:
52.21.152.96/3252.200.35.24/3252.200.50.23/3254.144.218.89/3254.221.221.197/3234.236.6.43/32
About the ClickHouse databases
ClickHouse native Experimentation uses the following databases in your ClickHouse service:- Data Export database: The database that your ClickHouse Data Export destination writes to. LaunchDarkly reads the experiment data that Data Export sends there.
- Metrics database: The database that holds the tables your metric data sources query. LaunchDarkly fills in the Data Export database, and you can change it if needed. The metrics database cannot be the results database.
- Results database: The database where LaunchDarkly writes experiment results. LaunchDarkly creates it the first time it connects, if it does not already exist.
ClickHouse naming conventions
When you select a project and environment, LaunchDarkly fills in default names for the ClickHouse experimentation user and the results database:- User:
ld_experimentation_user_<projkey>__<envkey>, where<projkey>is your project key and<envkey>is your environment key, in lowercase. - Results database:
ld_experimentation_<projkey>__<envkey>, in lowercase.
default.
You cannot change the results database name. Each environment gets its own results database, which keeps each environment’s experiment results separate. If another ClickHouse native Experimentation integration or a ClickHouse Data Export destination on the same ClickHouse service already uses the name, LaunchDarkly adds a number to the end, such as _2, when you generate the setup script. For example, environments with the keys prod-eu and prod_eu produce the same default name. The second environment to generate its setup script gets a results database that ends in _2.
Step 1: Configure the LaunchDarkly integration
Configure the ClickHouse native Experimentation integration in LaunchDarkly. This integration is a second LaunchDarkly integration that looks similar to the ClickHouse Data Export integration, but requires a separate setup process. To set up the integration:- Navigate to the Integrations page.
- Search for and select ClickHouse Native Experimentation.
- Click Add integration. The configuration page appears.
- Enter an integration Name.
- Choose the LaunchDarkly project and environment in Select project and environment. Only environments with a ClickHouse Data Export destination are available. You cannot change this after you save the integration. If the Data Export setup for the environment is not finished, LaunchDarkly displays a warning. Finish the Data Export setup before you continue.
- Review the Host and Port fields. LaunchDarkly automatically fills in these fields from your Data Export destination configuration. You cannot edit them.
- In the “Configure resource names” section of the form, review the Results database field. LaunchDarkly automatically fills in this field based on your selected project and environment. To learn more, read ClickHouse naming conventions.
- Review the User. LaunchDarkly fills in a default name, and you can change it if needed.
- Review the Metrics database name. LaunchDarkly fills in the Data Export database. If your metric event tables are in a different database, enter that database instead.
- Enter a Password for the ClickHouse experimentation user in the “Generate setup script” section of the form. Use only letters, digits, dashes (
-), and underscores (_). LaunchDarkly includes this password in the setup script. Save this password. You need it if you generate the script again. - Click Generate script. LaunchDarkly displays the “Setup script.”
- Copy the setup script.
- Open the draft from the integrations list.
- Enter the Password. If you already ran a setup script for this user, enter the same password you previously used.
- Click Generate script. LaunchDarkly displays the setup script.
- Continue with Step 2 if you have not run a setup script for this user yet, or if you changed the Metrics database name since you last ran one. Otherwise, continue with Step 3.
GRANT statements from the new script. The user already exists, which means you can skip the CREATE USER statement.
Step 2: Run the setup script in ClickHouse
Run the setup script before you save the integration. When you save, LaunchDarkly tests the connection as the ClickHouse experimentation user. The user and its privileges must already exist for this test to pass. To run the setup script:- Open the SQL console for your ClickHouse service as a user who can create users and grant privileges.
- Paste the setup script you copied in Step 1.
- Run the script.
- It creates the ClickHouse experimentation user with the password you entered. If a user with that name already exists, this statement fails, and the script does not change that user’s password.
- It grants the user privileges to create the results database, as well as to create tables in, write to, and read from that database.
- It grants the user read access to the Data Export database.
- It grants the user read access to the metrics database, if it is different from the Data Export database.
GRANT statements more than once. Each run produces the same result. If you run the whole script again after the user exists, the CREATE USER statement fails, and the user and its privileges from the earlier run stay in place.
The setup script gives the ClickHouse experimentation user read access only to the Data Export database and the metrics database. If a metric data source reads tables from another database, grant the experimentation user SELECT on that database as well.
The setup script does not restrict the experimentation user to specific hosts. If your ClickHouse service restricts inbound connections by IP address, add the LaunchDarkly IP addresses listed in the Prerequisites to its IP access list.
Step 3: Test the connection and save the integration
Next, return to LaunchDarkly to save the integration:- Return to the ClickHouse native Experimentation configuration page.
- After reading the Integration Terms and Conditions, check the I have read and agree to the Integration Terms and Conditions checkbox.
- Click Test connection and save. LaunchDarkly connects to ClickHouse as the experimentation user. If the connection succeeds, LaunchDarkly saves the integration and opens the integration’s page.
- If the error says “authentication failed,” check the User and Password. If you ran an earlier setup script for this user and then generated the script again with a different password, ClickHouse still has the earlier password. Enter the password you used then and click Generate script again, or choose a different User.
- If the error says “database not found,” check that the Data Export database and the metrics database you entered both exist in ClickHouse.
- If the error says “TLS handshake failed,” confirm that your ClickHouse service accepts native Transport Layer Security (TLS) connections on the port that the Data Export destination uses.
- If the error says “could not reach host,” check your ClickHouse IP access list. It must include the LaunchDarkly IP addresses listed in the Prerequisites.
Step 4: Verify the connection
Finally, verify the connection. On the integration’s page, check “Connection status” in the details panel. The status is one of the following:- Connected: LaunchDarkly can connect to ClickHouse and has the privileges it needs.
- Pending: LaunchDarkly has not finished setting up the results database yet.
- Degraded: LaunchDarkly connected to ClickHouse earlier, but its most recent attempt failed.
- Disconnected: LaunchDarkly could not connect to ClickHouse.
- Not connected: LaunchDarkly has no connection information for the integration yet.
Edit an existing integration
After you save the integration, the connection fields are read-only. The configuration page shows the setup script that granted LaunchDarkly access, without the password. You can change the integration Name and Status. LaunchDarkly saves each change as you make it. You can also update the maintainer and review connection health from the details panel. You cannot change the project, environment, host, port, user, password, results database, or metrics database. To change any of these values, delete the integration and create a new one. To delete the integration, click Delete integration, typeDELETE to confirm, and click Delete.