# ClickHouse

### Description

This ClickHouse destination can be used to send metrics, logs, and traces to a ClickHouse server.

### Supported Types

| Metrics | Logs | Traces | Bindplane Collector |
| ------- | ---- | ------ | ------------------- |
| ✓       | ✓    | ✓      | `v1.41.0`+          |

### Configuration

<table><thead><tr><th width="129.46484375">Field</th><th>Description</th></tr></thead><tbody><tr><td>Telemetry Types</td><td>The kind of telemetry that will be sent to the ClickHouse server. Can be any combination of logs, metrics, and traces.</td></tr><tr><td>Protocol</td><td>The kind of protocol to be used when sending to the ClickHouse server. Can be TCP, HTTP, or HTTPS. See this <a href="https://clickhouse.com/docs/en/interfaces/overview">ClickHouse documentation</a> for more information.</td></tr><tr><td>Endpoint</td><td>The endpoint to use to send telemetry data to ClickHouse. Supports multiple endpoints. See this <a href="https://clickhouse.com/docs/en/guides/sre/network-ports">ClickHouse documentation</a> for more information.</td></tr><tr><td>Username</td><td>Username to use to authenticate with the ClickHouse server. See this <a href="https://clickhouse.com/docs/en/operations/access-rights#user-account-management">ClickHouse documentation</a> for more information.</td></tr><tr><td>Password</td><td>Password to use to authenticate with the ClickHouse server. See this <a href="https://clickhouse.com/docs/en/operations/access-rights#user-account-management">ClickHouse documentation</a> for more information.</td></tr><tr><td>Database</td><td>Name of the database to use when interacting with the ClickHouse server.</td></tr><tr><td>Logs Table Name</td><td>Name of the table inside <code>Database</code> in ClickHouse to store log data in. Creates the table if it does not already exist.</td></tr><tr><td>Metrics Table Name</td><td>Name of the table inside <code>Database</code> in ClickHouse to store metric data in. Creates the table if it does not already exist.</td></tr><tr><td>Traces Table Name</td><td>Name of the table inside <code>Database</code> in ClickHouse to store traces data in. Creates the table if it does not already exist.</td></tr><tr><td>TTL</td><td>The data time-to-live, for example '30m'. 0 means no TTL. Make sure the telemetry sent has a timestamp field.</td></tr><tr><td>Timeout</td><td>Timeout for each attempt to send data to ClickHouse.</td></tr><tr><td>Connection Parameters</td><td>Additional connection parameters with map format. Used as query parameters in the URL. See this <a href="https://clickhouse.com/docs/en/integrations/go#connection-settings-1">ClickHouse documentation</a> for more information.</td></tr></tbody></table>

{% hint style="warning" %}
**IMPORTANT**

Metrics stored in ClickHouse are grouped by their type (sum, gauge, etc.) and stored in tables specific to that type by appending `_type` to the table name. For example, using the example configuration below, gauge metrics would be stored in `bpop.bp_metrics_gauge`. To read more, see this [documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/clickhouseexporter#metrics).
{% endhint %}

{% hint style="info" %}
**NOTE**

TLS can be configured using `Connection Parameters`. To do so, add an entry called \`secure\` with the value `true`. An example can be seen below.
{% endhint %}

{% hint style="danger" %}
**WARNING**

The collector will fail to start if it cannot reach the ClickHouse server on start up. If the ClickHouse server becomes unreachable while the collector is already running, it will continue running while reporting an error.

The collector can also fail to start if configured to use TTL, but the telemetry being sent lacks a `Timestamp` field.
{% endhint %}

This destination supports the [retry settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/retry-on-failure), the [sending queue settings](https://docs.bindplane.com/configuration/bindplane-otel-collector/sending-queue), and the [persistent queue settings.](https://docs.bindplane.com/configuration/bindplane-otel-collector/persistent-queue)

| Sending Queue | Persistent Queue | Retry on Failure |
| ------------- | ---------------- | ---------------- |
| ✓             | ✓                | ✓                |

### Example Configuration

Here we set a single endpoint that uses the TCP protocol. We are sending metrics, logs, and traces, so we have them selected and table names for them. We also utilize authentication and are setting compression and TLS via the connection parameters. Finally, we have the sending queue, persistent queue, and retry on failure enabled as well.

**Web Interface**

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-7d00b3f9038604ee1eafb5a71c22ead4996bb938%2Fintegrations-destinations-clickhouse-image-1.png?alt=media" alt="Bindplane docs - ClickHouse - image 1"><figcaption></figcaption></figure>

<figure><img src="https://1405008107-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgmiOMzBfoNFwmKJFHMcJ%2Fuploads%2Fgit-blob-4026cd62958267497b1a41e0944aeec5be513e07%2Fintegrations-destinations-clickhouse-image-2.png?alt=media" alt="Bindplane docs - ClickHouse - image 2"><figcaption></figcaption></figure>

**Standalone Destination**

```yaml
apiVersion: bindplane.observiq.com/v1
kind: Destination
metadata:
  id: clickhouse
  name: clickhouse
spec:
  type: clickhouse
  parameters:
    - name: telemetry_types
      value: ['Logs', 'Metrics', 'Traces']
    - name: protocol
      value: tcp
    - name: endpoint
      value: ['0.0.0.0:9000']
    - name: username
      value: admin
    - name: password
      value: admin
    - name: database
      value: bpop
    - name: logs_table_name
      value: bp_logs
    - name: metrics_table_name
      value: bp_metrics
    - name: traces_table_name
      value: bp_traces
    - name: connection_params
      value:
        compress: gzip
        secure: true
    - name: retry_on_failure_enabled
      value: 'true'
    - name: sending_queue_enabled
      value: 'true'
    - name: persistent_queue_enabled
      value: true
    - name: persistent_queue_storage_extension
      value: 
        type: file_storage_persistent_queue
        parameters:
          - name: persistent_queue_directory
            value: ${OIQ_OTEL_COLLECTOR_HOME}/storage
          - name: timeout
            value: 1
          - name: persistent_queue_fsync
            value: true
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/destinations/clickhouse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
