With the Coralogix JDBC driver, you can investigate your log data using SQL queries in your favorite database tool. You can quickly run SQL queries against the data already stored in your Coralogix account.

Java Database Connectivity (JDBC) is a common standard for database drivers, and many popular querying tools support it. This tutorial explains how to use the Coralogix JDBC driver with the popular tools DataGrip, DBeaver, and Tableau.

Note

Use this API to query high-tier data only.

## Getting started

Follow these steps to set up the connection to Coralogix:

1. Download the [latest driver](https://opensearch.org/docs/latest/search-plugins/sql/sql/jdbc/).

1. To use this API you need to [create](https://coralogix.com/docs/user-guides/account-management/api-keys/api-keys/index.md) a personal or team API key. Use permission presets when possible, as they update automatically with all relevant permissions. Alternatively, add individual permissions manually.

   | Preset       | Action                                                                                                                         | Description                                                                                      |
   | ------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ |
   | DataQuerying | `LEGACY-ARCHIVE-QUERIES:EXECUTE` `LOGS.DATA-API#HIGH:READDATA` `METRICS.DATA-API#HIGH:READDATA` `SPANS.DATA-API#HIGH:READDATA` | Query Data from the Archive Query Frequent Search Logs Query Metrics Query Frequent Search Spans |

1. Follow the client-specific instructions in the following sections. Other clients have a similar procedure for installing the driver.

1. Test the connection using a simple query: `SELECT * FROM logs LIMIT 5`

## DataGrip

1. In the Database menu, select the `+` icon, then select `Driver`.
1. In the `Name` field, enter `Coralogix`.
1. Under `Driver Files`, select the `+` icon, then select the driver file you downloaded earlier (Getting started, step 1).
1. Open the `Class` picker and select `org.opensearch.jdbc.Driver`.
1. Select `Apply`, then `OK`.
1. In the database menu, select the `+` icon, then select `Data Source`, then select `Coralogix`.
1. Replace `<cx_api_key>` with the generated API key value in the following JDBC URL, as per your team's cluster location.
1. In the `General` tab, change the URL as follows: `jdbc:opensearch://https://api.[[DOMAIN_VALUE]]/sql/<cx_api_key>`. Select the https://api.\[[DOMAIN_VALUE]\]/sql endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) using the domain selector at the top of the page.
1. Select `Apply`, then `OK`.

## DBeaver

1. In the top menu, select `Database`, then `Driver manager`, then select `New`.
1. In the `Driver Name` field, enter `Coralogix`.
1. In the Libraries tab, select `Add File`, then select the driver file you downloaded earlier (Getting started, step 1).
1. Select `Find Class`. Select `org.opensearch.jdbc.Driver` in the `Driver Class` field.
1. Select `OK`.
1. Select `Close`.
1. Select `Database/New Database Connection`, and make sure you select **All**.
1. Type `coralogix` into the search box and select the `Coralogix` driver. Select `Next`.
1. Replace `<cx_api_key>` with the generated API key value in the following JDBC URL, as per your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md).
1. Set `JDBC URL` to `jdbc:opensearch://https://api.[[DOMAIN_VALUE]]/sql/<cx_api_key>`. Select the https://api.\[[DOMAIN_VALUE]\]/sql endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) using the domain selector at the top of the page.
1. Select Test Connection to ensure it all works.
1. Select `OK`.

## Tableau

1. Download the [cx_sql_jdbc.taco](https://github.com/coralogix/tableau_jdbc_connector/blob/main/cx_sql_jdbc.taco) connector file, and copy it to:

   - Windows: `C:\\Users\\%USERNAME%\\Documents\\My Tableau Repository\\Connectors`
   - MacOS: `~/Documents/My Tableau Repository/Connectors`

1. Place the OpenSearch JDBC driver (jar file) downloaded earlier (Getting started, step 1) into:

   - Windows: `C:\\Program Files\\Tableau\\Drivers`
   - MacOS: `~/Library/Tableau/Drivers`

1. Run the Tableau Desktop with the command line flag `DDisableVerifyConnectorPluginSignature=true`:

   - Windows: `C:\\Program Files\\Tableau\\Tableau 2022.1\\bin\\tableau.exe" -DDisableVerifyConnectorPluginSignature=true`
   - MacOS: `open -n /Applications/Tableau\\ Desktop\\ 2022.1.app --args -DDisableVerifyConnectorPluginSignature=true`

   Adjust the command line according to the Tableau version you have. You can create a shortcut or a script to simplify this step.

1. Replace `<cx_api_key>` with the generated API key value in the following JDBC URL, as per your team's cluster location.

1. Open Tableau and select Server, then Coralogix by Coralogix.

1. Set the `JDBC URL` to: `jdbc:opensearch://https://api.[[DOMAIN_VALUE]]/sql/<cx_api_key>`. Select the https://api.\[[DOMAIN_VALUE]\]/sql endpoint that corresponds to your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md) using the domain selector at the top of the page.

## Additional resources

|                     |                                                                                                                                                |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| API                 | [Direct Lucene & DataPrime Query HTTP API](https://coralogix.com/docs/developer-portal/apis/data-query/direct-archive-query-http-api/index.md) |
| External            | [OpenDistro SQL](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/sql-full-text/)                                                  |
| Coralogix Endpoints | [Coralogix Endpoints](https://coralogix.com/docs/integrations/coralogix-endpoints/index.md)                                                    |
