Goal
In this guide, we will use the ClickHouse JDBC driver to connect ClickHouse to Splunk. We will install a local version of Splunk Enterprise but we’re not indexing any data. Instead, we’re using the search functions through the DB Connect query engine. With this guide, you will be able to create a dashboard connected to ClickHouse similar to this:This guide uses the New York City Taxi dataset. There are many other datasets that you can use from our docs.
Prerequisites
Before you get started you will need:- Splunk Enterprise to use search head functions
- Java Runtime Environment (JRE) requirements installed on your OS or container
- Splunk DB Connect
- Admin or SSH access to your Splunk Enterprise OS Instance
- ClickHouse connection details (see here if you’re using ClickHouse Cloud)
Install and configure DB Connect on Splunk Enterprise
You must first install the Java Runtime Environment on your Splunk Enterprise instance. If you’re using Docker, you can use the commandmicrodnf install java-11-openjdk.
Note down the java_home path: java -XshowSettings:properties -version.
Ensure that the DB Connect App is installed on Splunk Enterprise. You can find it in the Apps section of the Splunk Web UI:
- Log in to Splunk Web and go to Apps > Find More Apps
- Use the search box to find DB Connect
- Click the green “Install” button next to Splunk DB Connect
- Click “Restart Splunk”
Configure JDBC for ClickHouse
Download the ClickHouse JDBC driver JAR file and copy it to the DB Connect Drivers folder at:$SPLUNK_HOME/etc/apps/splunk_app_db_connect/local/db_connection_types.conf to add the ClickHouse JDBC Driver class details. Add the following stanza to db_connection_types.conf:
$SPLUNK_HOME/bin/splunk restart.
Navigate back to the DB Connect App and go to Configuration > Settings > Drivers. You should see a green tick next to ClickHouse:
Connect Splunk search to ClickHouse
Navigate to DB Connect App Configuration -> Databases -> Identities: Create a Identity for your ClickHouse. Create a new Connection to ClickHouse from Configuration -> Databases -> Connections and select “New Connection”.Add ClickHouse host details and ensure “Enable SSL” is ticked: After saving the connection, you will have successfully connected to ClickHouse to Splunk!
If you receive an error, make sure that you have added the IP address of your Splunk instance to the ClickHouse Cloud IP Access List. See the docs for more info.
Run a SQL query
We will now run a SQL query to test that everything works. Select your connection details in the SQL Explorer from the DataLab section of the DB Connect App. We’re using thetrips table for this demo:
Execute a SQL query on the trips table that returns the count of all the records in the table:
If your query is successful, you should see the results.