diff --git a/clickhouse/assets/configuration/spec.yaml b/clickhouse/assets/configuration/spec.yaml index d5d042cebf06f..aab99aceb72c2 100644 --- a/clickhouse/assets/configuration/spec.yaml +++ b/clickhouse/assets/configuration/spec.yaml @@ -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: diff --git a/clickhouse/changelog.d/19018.added b/clickhouse/changelog.d/19018.added new file mode 100644 index 0000000000000..26114bc6658d1 --- /dev/null +++ b/clickhouse/changelog.d/19018.added @@ -0,0 +1 @@ +Add verify option when connecting to ClickHouse server. \ No newline at end of file diff --git a/clickhouse/datadog_checks/clickhouse/clickhouse.py b/clickhouse/datadog_checks/clickhouse/clickhouse.py index fe362e96f47ae..bcc20a63af849 100644 --- a/clickhouse/datadog_checks/clickhouse/clickhouse.py +++ b/clickhouse/datadog_checks/clickhouse/clickhouse.py @@ -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 @@ -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), diff --git a/clickhouse/datadog_checks/clickhouse/config_models/defaults.py b/clickhouse/datadog_checks/clickhouse/config_models/defaults.py index a5d5bee5638dd..cda1a5793bb1c 100644 --- a/clickhouse/datadog_checks/clickhouse/config_models/defaults.py +++ b/clickhouse/datadog_checks/clickhouse/config_models/defaults.py @@ -50,3 +50,7 @@ def instance_use_global_custom_queries(): def instance_username(): return 'default' + + +def instance_verify(): + return True diff --git a/clickhouse/datadog_checks/clickhouse/config_models/instance.py b/clickhouse/datadog_checks/clickhouse/config_models/instance.py index 438b23dc2919a..6a6f674ab672e 100644 --- a/clickhouse/datadog_checks/clickhouse/config_models/instance.py +++ b/clickhouse/datadog_checks/clickhouse/config_models/instance.py @@ -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): diff --git a/clickhouse/datadog_checks/clickhouse/data/conf.yaml.example b/clickhouse/datadog_checks/clickhouse/data/conf.yaml.example index 9dbea83674bd1..1ec572d1839bf 100644 --- a/clickhouse/datadog_checks/clickhouse/data/conf.yaml.example +++ b/clickhouse/datadog_checks/clickhouse/data/conf.yaml.example @@ -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. diff --git a/clickhouse/tests/test_unit.py b/clickhouse/tests/test_unit.py index b49ae2060b9fc..b70723d34d3cf 100644 --- a/clickhouse/tests/test_unit.py +++ b/clickhouse/tests/test_unit.py @@ -30,6 +30,7 @@ def test_config(instance): compression=False, secure=False, ca_certs=None, + verify=True, settings={}, client_name='datadog-test-clickhouse', )