Skip to content

Commit

Permalink
Add the verify option to clickhouse (#19018)
Browse files Browse the repository at this point in the history
* add the verify option to clickhouse

* fix changelog

* Update clickhouse/assets/configuration/spec.yaml

Co-authored-by: Esther Kim <[email protected]>

* Update clickhouse/datadog_checks/clickhouse/data/conf.yaml.example

Co-authored-by: Esther Kim <[email protected]>

---------

Co-authored-by: Esther Kim <[email protected]>
  • Loading branch information
HadhemiDD and estherk15 authored Nov 22, 2024
1 parent 607cf5b commit fc8bd07
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clickhouse/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ files:
value:
type: boolean
example: False
- name: verify
description: Indicates if a certificate is required and if it will be validated after a connection is established.
value:
type: boolean
example: True
- template: instances/db
overrides:
custom_queries.value.example:
Expand Down
1 change: 1 addition & 0 deletions clickhouse/changelog.d/19018.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add verify option when connecting to ClickHouse server.
2 changes: 2 additions & 0 deletions clickhouse/datadog_checks/clickhouse/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, name, init_config, instances):
self._compression = self.instance.get('compression', False)
self._tls_verify = is_affirmative(self.instance.get('tls_verify', False))
self._tls_ca_cert = self.instance.get('tls_ca_cert', None)
self._verify = self.instance.get('verify', True)
self._tags = self.instance.get('tags', [])

# Add global tags
Expand Down Expand Up @@ -110,6 +111,7 @@ def connect(self):
compression=self._compression,
secure=self._tls_verify,
ca_certs=self._tls_ca_cert,
verify=self._verify,
settings={},
# Make every client unique for server logs
client_name='datadog-{}'.format(self.check_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ def instance_use_global_custom_queries():

def instance_username():
return 'default'


def instance_verify():
return True
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class InstanceConfig(BaseModel):
tls_verify: Optional[bool] = None
use_global_custom_queries: Optional[str] = None
username: Optional[str] = None
verify: Optional[bool] = None

@model_validator(mode='before')
def _initial_validation(cls, values):
Expand Down
5 changes: 5 additions & 0 deletions clickhouse/datadog_checks/clickhouse/data/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ instances:
#
# tls_verify: false

## @param verify - boolean - optional - default: true
## Indicates if a certificate is required and if it will be validated after a connection is established.
#
# verify: true

## @param only_custom_queries - boolean - optional - default: false
## Set this parameter to `true` if you want to skip the integration's default metrics collection.
## Only metrics specified in `custom_queries` will be collected.
Expand Down
1 change: 1 addition & 0 deletions clickhouse/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_config(instance):
compression=False,
secure=False,
ca_certs=None,
verify=True,
settings={},
client_name='datadog-test-clickhouse',
)
Expand Down

0 comments on commit fc8bd07

Please sign in to comment.