|
| 1 | +--- |
| 2 | +title: "ClickHouse" |
| 3 | +description: "Include connection details from a ClickHouse server" |
| 4 | +tags: ["collect"] |
| 5 | +--- |
| 6 | + |
| 7 | +The data collector will validate and add information about a ClickHouse server to a support bundle. |
| 8 | + |
| 9 | +## Parameters |
| 10 | + |
| 11 | +The data collector has the following parameters: |
| 12 | + |
| 13 | +#### `collectorName` (Recommended) |
| 14 | +The name of the collector. |
| 15 | +This is recommended to set to a string identifying the ClickHouse instance, and can be used to refer to this collector in analyzers and preflight checks. |
| 16 | +If unset, this will be set to the string "clickhouse". |
| 17 | + |
| 18 | +#### `uri` (Required) |
| 19 | +The connection URI to use when connecting to the ClickHouse server. The ClickHouse collector uses the clickhous-go [`ParseDSN()`](https://pkg.go.dev/github.com/ClickHouse/clickhouse-go/v2#ParseDSN) function which expects URL-encoded connection strings. This relies on `url.Parse()`(https://pkg.go.dev/net/url#Parse) to parse the connection URI. |
| 20 | +If your password contains special characters, like `@`, `#`, `&`, etc., you may need to URL-encode the password. |
| 21 | + |
| 22 | +#### `tls` (Optional) |
| 23 | + |
| 24 | +TLS parameters are required whenever connections to the target ClickHouse server are encrypted using TLS. The server can be configured to authenticate clients (`mTLS`) or to secure the connection (`TLS`). This is controlled via the `verificationMode` setting in the Clickhouse Configuration. If `verificationMode` is strict, ClickHouse will additinally validate the client certificate. See the [OpenSSL configuration settings of ClickHouse](https://clickhouse.com/docs/operations/server-configuration-parameters/settings#openssl) for more details. |
| 25 | + |
| 26 | +In `mTLS` mode, the required parameters are `client certificate`, `private key` and a `CA certificate`. If the server is configured to encrypt only the connection, then only the `CA certificate` is required. When the `skipVerify` option is set to `true`, then verifying the server certificate can be skipped. The `skipVerify` option is available only in `TLS` mode. |
| 27 | + |
| 28 | +## Example Collector Definitions |
| 29 | + |
| 30 | +Plain text connection to a server: |
| 31 | +```yaml |
| 32 | +apiVersion: troubleshoot.sh/v1beta2 |
| 33 | +kind: SupportBundle |
| 34 | +metadata: |
| 35 | + name: sample |
| 36 | +spec: |
| 37 | + collectors: |
| 38 | + - clickhouse: |
| 39 | + collectorName: clickhouse-collector |
| 40 | + uri: clickhouse://user:password@hostname:9000/defaultdb |
| 41 | +``` |
| 42 | +
|
| 43 | +URL-encoded password with special characters, using [Helm's `urlquery` function](https://helm.sh/docs/chart_template_guide/function_list/#urlquery): |
| 44 | +```yaml |
| 45 | +apiVersion: troubleshoot.sh/v1beta2 |
| 46 | +kind: SupportBundle |
| 47 | +metadata: |
| 48 | + name: sample |
| 49 | +spec: |
| 50 | + collectors: |
| 51 | + - clickhouse: |
| 52 | + collectorName: clickhouse-collector |
| 53 | + uri: 'clickhouse://{{ $db_user | urlquery }}:{{ $db_pass | urlquery }}@{{ $db_host }}:{{ $db_port }}/{{ $db_name }}' |
| 54 | +``` |
| 55 | + |
| 56 | +Secured (`mTLS`) connection to a server with inline TLS parameter configurations. The parameters must be in `PEM` format: |
| 57 | +```yaml |
| 58 | +apiVersion: troubleshoot.sh/v1beta2 |
| 59 | +kind: SupportBundle |
| 60 | +metadata: |
| 61 | + name: sample |
| 62 | +spec: |
| 63 | + collectors: |
| 64 | + - clickhouse: |
| 65 | + collectorName: clickhouse-collector |
| 66 | + uri: clickhouse://user:password@hostname:9000/defaultdb |
| 67 | + tls: |
| 68 | + cacert: | |
| 69 | + -----BEGIN CERTIFICATE----- |
| 70 | + ... |
| 71 | + <truncated> |
| 72 | + ... |
| 73 | + -----END CERTIFICATE----- |
| 74 | + clientCert: | |
| 75 | + -----BEGIN CERTIFICATE----- |
| 76 | + ... |
| 77 | + <truncated> |
| 78 | + ... |
| 79 | + -----END CERTIFICATE----- |
| 80 | + clientKey: | |
| 81 | + -----BEGIN RSA PRIVATE KEY----- |
| 82 | + ... |
| 83 | + <truncated> |
| 84 | + ... |
| 85 | + -----END RSA PRIVATE KEY----- |
| 86 | +``` |
| 87 | + |
| 88 | +Secured (`mTLS`) connection to a server with TLS parameters stored in a Kubernetes secret as `stringData`. The parameters must be in `PEM` format: |
| 89 | +```yaml |
| 90 | +apiVersion: troubleshoot.sh/v1beta2 |
| 91 | +kind: Preflight |
| 92 | +metadata: |
| 93 | + name: sample |
| 94 | +spec: |
| 95 | + collectors: |
| 96 | + - clickhouse: |
| 97 | + collectorName: clickhouse-collector |
| 98 | + uri: clickhouse://user:password@hostname:9000/defaultdb |
| 99 | + tls: |
| 100 | + secret: |
| 101 | + # This secret must contain the following keys: |
| 102 | + # cacert: <CA PEM cert> |
| 103 | + # clientCert: <Client PEM cert> if mTLS |
| 104 | + # clientKey: <Client PEM key> if mTLS |
| 105 | + name: pg-tls-secret |
| 106 | + namespace: default |
| 107 | +``` |
| 108 | + |
| 109 | +Encrypted (`TLS`) connection to a server with TLS parameters inline. The parameters must be in `PEM` format. In this case, the server is configured not to authenticate clients: |
| 110 | +```yaml |
| 111 | +apiVersion: troubleshoot.sh/v1beta2 |
| 112 | +kind: Preflight |
| 113 | +metadata: |
| 114 | + name: dbs-collector |
| 115 | +spec: |
| 116 | + collectors: |
| 117 | + - clickhouse: |
| 118 | + collectorName: clickhouse-collector |
| 119 | + uri: clickhouse://user:password@hostname:9000/defaultdb |
| 120 | + tls: |
| 121 | + cacert: | |
| 122 | + -----BEGIN CERTIFICATE----- |
| 123 | + ... |
| 124 | + <truncated> |
| 125 | + ... |
| 126 | + -----END CERTIFICATE----- |
| 127 | +``` |
| 128 | + |
| 129 | +Skip verification of the server certificate when creating an encrypted connection. This works only if the ClickHouse server has `verificationMode` set to `relaxed`. This means the connection will not validate the signing of the ClickHouse server certificate. The connection remains encrypted: |
| 130 | +```yaml |
| 131 | +apiVersion: troubleshoot.sh/v1beta2 |
| 132 | +kind: Preflight |
| 133 | +metadata: |
| 134 | + name: dbs-collector |
| 135 | +spec: |
| 136 | + collectors: |
| 137 | + - clickhouse: |
| 138 | + collectorName: clickhouse-collector |
| 139 | + uri: clickhouse://user:password@hostname:9000/defaultdb |
| 140 | + tls: |
| 141 | + skipVerify: true |
| 142 | +``` |
| 143 | + |
| 144 | +## Included resources |
| 145 | + |
| 146 | +A single JSON file will be added to the support bundle, in the path `/clickhouse/[collector-name].json`: |
| 147 | + |
| 148 | +```json |
| 149 | +{ |
| 150 | + "isConnected": false, |
| 151 | + "error": "Code: 241. DB::Exception: Received from ***:9000 ....", |
| 152 | + "version": "10.12", |
| 153 | +} |
| 154 | +``` |
| 155 | + |
| 156 | +### Fields |
| 157 | + |
| 158 | +#### `isConnected` |
| 159 | +a boolean indicating if the collector was able to connect and authenticate using the connection string provided. |
| 160 | + |
| 161 | +#### `error` |
| 162 | +a string that indicates the connection error, if there was one. |
| 163 | + |
| 164 | +#### `version` |
| 165 | +when connected, a string indicating the version of ClickHouse that's running. Note that it is a valid Semver version, meaning |
| 166 | +commit information has been stripped from the version. |
0 commit comments