Skip to content

Commit ba84005

Browse files
Cleanup code to have only query activity
1 parent 7b0c023 commit ba84005

File tree

12 files changed

+1458
-1254
lines changed

12 files changed

+1458
-1254
lines changed

clickhouse/assets/configuration/spec.yaml

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ files:
7676
example: True
7777
- name: dbm
7878
description: |
79-
Enable Database Monitoring (DBM) to collect query samples and execution plans.
79+
Enable Database Monitoring (DBM) to collect query activity, metrics, and samples.
8080
This feature provides deep observability into query performance.
8181
value:
8282
type: boolean
@@ -95,63 +95,37 @@ files:
9595
value:
9696
type: boolean
9797
example: false
98-
- name: query_samples
99-
description: Configure collection of query samples
98+
- name: query_activity
99+
description: Configure collection of database activity snapshots from system.processes
100100
options:
101101
- name: enabled
102102
description: |
103-
Enable collection of query samples. Requires `dbm: true`.
103+
Enable collection of database activity snapshots. Requires `dbm: true`.
104+
Activity snapshots show currently executing queries and connection counts.
104105
value:
105106
type: boolean
106107
example: true
107108
- name: collection_interval
108109
description: |
109-
Set the query sample collection interval (in seconds). Each collection involves a single query to
110+
Set the activity snapshot collection interval (in seconds). Each collection involves a single query to
110111
`system.processes` to capture currently executing queries.
111112
value:
112113
type: number
113114
example: 1
114-
- name: samples_per_hour_per_query
115-
description: |
116-
Set the rate limit for how many query sample events will be ingested per hour per normalized query.
117-
value:
118-
type: integer
119-
example: 15
120-
- name: seen_samples_cache_maxsize
115+
- name: payload_row_limit
121116
description: |
122-
Set the max size of the cache used for the samples_per_hour_per_query rate limit. This should be increased
123-
for databases with a very large number of unique normalized queries which exceed the cache's limit.
117+
Set the maximum number of active sessions to include in each activity snapshot.
124118
value:
125119
type: integer
126-
example: 10000
120+
example: 1000
127121
- name: run_sync
128122
hidden: true
129123
description: |
130-
Run the query samples collection synchronously. This is useful for testing purposes, but should not be used
124+
Run the activity collection synchronously. This is useful for testing purposes, but should not be used
131125
in production as it can block the main thread and cause performance issues.
132126
value:
133127
type: boolean
134128
example: false
135-
- name: activity_enabled
136-
description: |
137-
Enable collection of database activity snapshots. Requires `dbm: true`.
138-
value:
139-
type: boolean
140-
example: true
141-
- name: activity_collection_interval
142-
hidden: true
143-
description: |
144-
Set the activity snapshot collection interval (in seconds). This number cannot be smaller than
145-
the `query_samples` configured collection_interval.
146-
value:
147-
type: number
148-
example: 10
149-
- name: activity_max_rows
150-
description: |
151-
Set the maximum number of active sessions to include in each activity snapshot.
152-
value:
153-
type: integer
154-
example: 1000
155129
- name: query_metrics
156130
description: Configure collection of query metrics
157131
options:

clickhouse/datadog_checks/clickhouse/clickhouse.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .__about__ import __version__
1616
from .completed_query_samples import ClickhouseCompletedQuerySamples
1717
from .config import build_config
18-
from .statement_samples import ClickhouseStatementSamples
18+
from .statement_activity import ClickhouseStatementActivity
1919
from .statements import ClickhouseStatementMetrics
2020
from .utils import ErrorSanitizer
2121

@@ -91,11 +91,11 @@ def _init_dbm_components(self):
9191
else:
9292
self.statement_metrics = None
9393

94-
# Initialize query samples (from system.processes - analogous to pg_stat_activity)
95-
if self._config.dbm and self._config.query_samples.enabled:
96-
self.statement_samples = ClickhouseStatementSamples(self, self._config.query_samples)
94+
# Initialize query activity (from system.processes - analogous to pg_stat_activity)
95+
if self._config.dbm and self._config.query_activity.enabled:
96+
self.statement_activity = ClickhouseStatementActivity(self, self._config.query_activity)
9797
else:
98-
self.statement_samples = None
98+
self.statement_activity = None
9999

100100
# Initialize completed query samples (from system.query_log - completed queries)
101101
if self._config.dbm and self._config.completed_query_samples.enabled:
@@ -182,9 +182,9 @@ def check(self, _):
182182
if self.statement_metrics:
183183
self.statement_metrics.run_job_loop(self.tags)
184184

185-
# Run statement samples if DBM is enabled (from system.processes)
186-
if self.statement_samples:
187-
self.statement_samples.run_job_loop(self.tags)
185+
# Run query activity collection if DBM is enabled (from system.processes)
186+
if self.statement_activity:
187+
self.statement_activity.run_job_loop(self.tags)
188188

189189
# Run completed query samples if DBM is enabled (from system.query_log)
190190
if self.completed_query_samples:

0 commit comments

Comments
 (0)