gitlab-exporter 16.4.1 → 16.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/gitlab_exporter/database/zoekt.rb +205 -11
- data/lib/gitlab_exporter/version.rb +1 -1
- data/spec/database/zoekt_spec.rb +149 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 741207042e803e24cf2a73e9c622606dc6814a7f335a1e512940977afac6d049
|
|
4
|
+
data.tar.gz: 27e0ec1192f33b5835e61ddd2a86df4c131673f2c46b11217648c6edc274e64b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c5f33d6126b18c3da6ae392c5959ee6ca8b361b9af93e24fd5d9f07aa296d4dfd53717bb87fa05496570b3480b4d19ee3512e22ea6a13931a7234e4d1f5f6c6
|
|
7
|
+
data.tar.gz: 3df0acd00f63f87a674907a70e65b4be172be997c323bfd5c36d3d56fc89cbe7ee72e108c395e674b1075a4618a10befab07ae4b158008c91a102475107d89ce
|
data/Gemfile.lock
CHANGED
|
@@ -62,13 +62,51 @@ module GitLab
|
|
|
62
62
|
LIMIT 1
|
|
63
63
|
SQL
|
|
64
64
|
|
|
65
|
+
ZOEKT_NODE_STORAGE_QUERY = <<~SQL.freeze
|
|
66
|
+
SELECT
|
|
67
|
+
id,
|
|
68
|
+
metadata ->> 'name' AS node_name,
|
|
69
|
+
unclaimed_storage_bytes,
|
|
70
|
+
storage_percent_used
|
|
71
|
+
FROM zoekt_nodes
|
|
72
|
+
SQL
|
|
73
|
+
|
|
74
|
+
ZOEKT_REPOSITORIES_STATE_QUERY = <<~SQL.freeze
|
|
75
|
+
SELECT state, COUNT(*) FROM zoekt_repositories GROUP BY state
|
|
76
|
+
SQL
|
|
77
|
+
|
|
78
|
+
ZOEKT_INDICES_STATE_QUERY = <<~SQL.freeze
|
|
79
|
+
SELECT state, COUNT(*) FROM zoekt_indices GROUP BY state
|
|
80
|
+
SQL
|
|
81
|
+
|
|
82
|
+
ZOEKT_INDICES_WATERMARK_QUERY = <<~SQL.freeze
|
|
83
|
+
SELECT watermark_level, COUNT(*) FROM zoekt_indices GROUP BY watermark_level
|
|
84
|
+
SQL
|
|
85
|
+
|
|
86
|
+
ZOEKT_INDICES_STORAGE_QUERY = <<~SQL.freeze
|
|
87
|
+
SELECT
|
|
88
|
+
zoekt_indices.id,
|
|
89
|
+
zoekt_indices.reserved_storage_bytes,
|
|
90
|
+
zoekt_indices.used_storage_bytes,
|
|
91
|
+
zoekt_nodes.metadata ->> 'name' AS node_name
|
|
92
|
+
FROM
|
|
93
|
+
zoekt_indices
|
|
94
|
+
INNER JOIN
|
|
95
|
+
zoekt_nodes ON zoekt_indices.zoekt_node_id = zoekt_nodes.id
|
|
96
|
+
SQL
|
|
97
|
+
|
|
65
98
|
def run
|
|
66
99
|
return {} unless zoekt_indexing_enabled?
|
|
67
100
|
|
|
68
101
|
{
|
|
69
102
|
task_processing_query_result: execute(ZOEKT_TASKS_PROCESSING_QUERY, [Time.now.utc]),
|
|
70
103
|
repositories_schema_version_query_result: repositories_schema_version_query_result,
|
|
71
|
-
zoekt_nodes_status_query_result: execute(ZOEKT_NODES_STATUS_QUERY)
|
|
104
|
+
zoekt_nodes_status_query_result: execute(ZOEKT_NODES_STATUS_QUERY),
|
|
105
|
+
node_storage_query_result: execute(ZOEKT_NODE_STORAGE_QUERY),
|
|
106
|
+
repositories_state_query_result: execute(ZOEKT_REPOSITORIES_STATE_QUERY),
|
|
107
|
+
indices_state_query_result: execute(ZOEKT_INDICES_STATE_QUERY),
|
|
108
|
+
indices_watermark_query_result: execute(ZOEKT_INDICES_WATERMARK_QUERY),
|
|
109
|
+
indices_storage_query_result: execute(ZOEKT_INDICES_STORAGE_QUERY)
|
|
72
110
|
}.compact
|
|
73
111
|
end
|
|
74
112
|
|
|
@@ -131,6 +169,7 @@ module GitLab
|
|
|
131
169
|
end
|
|
132
170
|
|
|
133
171
|
# The prober which is called when gathering metrics
|
|
172
|
+
# rubocop:disable Metrics/ClassLength
|
|
134
173
|
class ZoektProber
|
|
135
174
|
PrometheusMetrics.describe(
|
|
136
175
|
"search_zoekt_task_processing_queue_size",
|
|
@@ -150,6 +189,48 @@ module GitLab
|
|
|
150
189
|
"gauge"
|
|
151
190
|
)
|
|
152
191
|
|
|
192
|
+
PrometheusMetrics.describe(
|
|
193
|
+
"search_zoekt_node_unclaimed_storage_bytes",
|
|
194
|
+
"Unclaimed storage bytes for Zoekt node",
|
|
195
|
+
"gauge"
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
PrometheusMetrics.describe(
|
|
199
|
+
"search_zoekt_node_storage_percent_used",
|
|
200
|
+
"Fraction of storage used on Zoekt node (0..1)",
|
|
201
|
+
"gauge"
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
PrometheusMetrics.describe(
|
|
205
|
+
"search_zoekt_repositories_states_total",
|
|
206
|
+
"Number of Zoekt repositories in each state",
|
|
207
|
+
"gauge"
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
PrometheusMetrics.describe(
|
|
211
|
+
"search_zoekt_indices_states",
|
|
212
|
+
"Number of Zoekt indices in each state",
|
|
213
|
+
"gauge"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
PrometheusMetrics.describe(
|
|
217
|
+
"search_zoekt_indices_watermark_levels",
|
|
218
|
+
"Number of Zoekt indices in each watermark level",
|
|
219
|
+
"gauge"
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
PrometheusMetrics.describe(
|
|
223
|
+
"search_zoekt_indices_reserved_storage_bytes",
|
|
224
|
+
"Reserved storage bytes for each Zoekt index",
|
|
225
|
+
"gauge"
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
PrometheusMetrics.describe(
|
|
229
|
+
"search_zoekt_indices_used_storage_bytes",
|
|
230
|
+
"Used storage bytes for each Zoekt index",
|
|
231
|
+
"gauge"
|
|
232
|
+
)
|
|
233
|
+
|
|
153
234
|
def initialize(metrics: PrometheusMetrics.new, **opts)
|
|
154
235
|
@metrics = metrics
|
|
155
236
|
@collector = opts[:collector] || ZoektCollector.new(**opts)
|
|
@@ -157,21 +238,60 @@ module GitLab
|
|
|
157
238
|
|
|
158
239
|
def probe_db
|
|
159
240
|
results = @collector.run
|
|
160
|
-
results
|
|
161
|
-
add_processing_zoekt_tasks_to_metric(row)
|
|
162
|
-
end
|
|
163
|
-
results[:repositories_schema_version_query_result]&.each do |row|
|
|
164
|
-
add_zoekt_repositories_by_schema_version_to_metric(row)
|
|
165
|
-
end
|
|
166
|
-
results[:zoekt_nodes_status_query_result]&.each do |row|
|
|
167
|
-
add_zoekt_nodes_status_to_metric(row)
|
|
168
|
-
end
|
|
169
|
-
|
|
241
|
+
process_results(results)
|
|
170
242
|
self
|
|
171
243
|
rescue PG::ConnectionBad
|
|
172
244
|
self
|
|
173
245
|
end
|
|
174
246
|
|
|
247
|
+
private
|
|
248
|
+
|
|
249
|
+
def process_results(results)
|
|
250
|
+
process_task_results(results[:task_processing_query_result])
|
|
251
|
+
process_repository_results(results[:repositories_schema_version_query_result])
|
|
252
|
+
process_node_status_results(results[:zoekt_nodes_status_query_result])
|
|
253
|
+
process_node_storage_results(results[:node_storage_query_result])
|
|
254
|
+
process_repositories_state_results(results[:repositories_state_query_result])
|
|
255
|
+
process_indices_state_results(results[:indices_state_query_result])
|
|
256
|
+
process_indices_watermark_results(results[:indices_watermark_query_result])
|
|
257
|
+
process_indices_storage_results(results[:indices_storage_query_result])
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def process_task_results(results)
|
|
261
|
+
results.to_a.each { |row| add_processing_zoekt_tasks_to_metric(row) }
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def process_repository_results(results)
|
|
265
|
+
results&.each { |row| add_zoekt_repositories_by_schema_version_to_metric(row) }
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def process_node_status_results(results)
|
|
269
|
+
results&.each { |row| add_zoekt_nodes_status_to_metric(row) }
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def process_node_storage_results(results)
|
|
273
|
+
results&.each do |row|
|
|
274
|
+
add_zoekt_node_unclaimed_storage_to_metric(row)
|
|
275
|
+
add_zoekt_node_storage_percent_used_to_metric(row)
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def process_repositories_state_results(results)
|
|
280
|
+
results&.each { |row| add_zoekt_repositories_state_to_metric(row) }
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def process_indices_state_results(results)
|
|
284
|
+
results&.each { |row| add_zoekt_indices_state_to_metric(row) }
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def process_indices_watermark_results(results)
|
|
288
|
+
results&.each { |row| add_zoekt_indices_watermark_to_metric(row) }
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def process_indices_storage_results(results)
|
|
292
|
+
results&.each { |row| add_zoekt_indices_storage_to_metric(row) }
|
|
293
|
+
end
|
|
294
|
+
|
|
175
295
|
def add_processing_zoekt_tasks_to_metric(row)
|
|
176
296
|
@metrics.add(
|
|
177
297
|
"search_zoekt_task_processing_queue_size",
|
|
@@ -206,10 +326,84 @@ module GitLab
|
|
|
206
326
|
)
|
|
207
327
|
end
|
|
208
328
|
|
|
329
|
+
def add_zoekt_node_unclaimed_storage_to_metric(row)
|
|
330
|
+
@metrics.add(
|
|
331
|
+
"search_zoekt_node_unclaimed_storage_bytes",
|
|
332
|
+
row["unclaimed_storage_bytes"].to_i,
|
|
333
|
+
**{
|
|
334
|
+
zoekt_node_id: row["id"],
|
|
335
|
+
zoekt_node_name: row["node_name"]
|
|
336
|
+
}.compact
|
|
337
|
+
)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def add_zoekt_node_storage_percent_used_to_metric(row)
|
|
341
|
+
@metrics.add(
|
|
342
|
+
"search_zoekt_node_storage_percent_used",
|
|
343
|
+
row["storage_percent_used"].to_f,
|
|
344
|
+
**{
|
|
345
|
+
zoekt_node_id: row["id"],
|
|
346
|
+
zoekt_node_name: row["node_name"]
|
|
347
|
+
}.compact
|
|
348
|
+
)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def add_zoekt_repositories_state_to_metric(row)
|
|
352
|
+
@metrics.add(
|
|
353
|
+
"search_zoekt_repositories_states_total",
|
|
354
|
+
row["count"].to_i,
|
|
355
|
+
**{
|
|
356
|
+
state: row["state"]
|
|
357
|
+
}.compact
|
|
358
|
+
)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def add_zoekt_indices_state_to_metric(row)
|
|
362
|
+
@metrics.add(
|
|
363
|
+
"search_zoekt_indices_states",
|
|
364
|
+
row["count"].to_i,
|
|
365
|
+
**{
|
|
366
|
+
state: row["state"]
|
|
367
|
+
}.compact
|
|
368
|
+
)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def add_zoekt_indices_watermark_to_metric(row)
|
|
372
|
+
@metrics.add(
|
|
373
|
+
"search_zoekt_indices_watermark_levels",
|
|
374
|
+
row["count"].to_i,
|
|
375
|
+
**{
|
|
376
|
+
watermark_level: row["watermark_level"]
|
|
377
|
+
}.compact
|
|
378
|
+
)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
# rubocop:disable Metrics/MethodLength
|
|
382
|
+
def add_zoekt_indices_storage_to_metric(row)
|
|
383
|
+
@metrics.add(
|
|
384
|
+
"search_zoekt_indices_reserved_storage_bytes",
|
|
385
|
+
row["reserved_storage_bytes"].to_i,
|
|
386
|
+
**{
|
|
387
|
+
zoekt_index_id: row["id"],
|
|
388
|
+
zoekt_node_name: row["node_name"]
|
|
389
|
+
}.compact
|
|
390
|
+
)
|
|
391
|
+
@metrics.add(
|
|
392
|
+
"search_zoekt_indices_used_storage_bytes",
|
|
393
|
+
row["used_storage_bytes"].to_i,
|
|
394
|
+
**{
|
|
395
|
+
zoekt_index_id: row["id"],
|
|
396
|
+
zoekt_node_name: row["node_name"]
|
|
397
|
+
}.compact
|
|
398
|
+
)
|
|
399
|
+
end
|
|
400
|
+
# rubocop:enable Metrics/MethodLength
|
|
401
|
+
|
|
209
402
|
def write_to(target)
|
|
210
403
|
target.write(@metrics.to_s)
|
|
211
404
|
end
|
|
212
405
|
end
|
|
406
|
+
# rubocop:enable Metrics/ClassLength
|
|
213
407
|
end
|
|
214
408
|
end
|
|
215
409
|
end
|
data/spec/database/zoekt_spec.rb
CHANGED
|
@@ -11,6 +11,31 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
11
11
|
let(:zoekt_repository_schema_version_query) { described_class::ZOEKT_REPOSITORY_SCHEMA_VERSION_QUERY }
|
|
12
12
|
let(:zoekt_nodes_status_query) { described_class::ZOEKT_NODES_STATUS_QUERY }
|
|
13
13
|
let(:zoekt_nodes_status_query_results) { [{ "id" => "1", "name" => "foo", "status" => "1" }] }
|
|
14
|
+
let(:zoekt_node_storage_query) { described_class::ZOEKT_NODE_STORAGE_QUERY }
|
|
15
|
+
let(:zoekt_node_storage_query_results) do
|
|
16
|
+
[{ "id" => "1", "node_name" => "foo", "unclaimed_storage_bytes" => "1000000", "storage_percent_used" => "0.75" }]
|
|
17
|
+
end
|
|
18
|
+
let(:zoekt_repositories_state_query) { described_class::ZOEKT_REPOSITORIES_STATE_QUERY }
|
|
19
|
+
let(:zoekt_repositories_state_query_results) do
|
|
20
|
+
[{ "state" => "0", "count" => "5" }, { "state" => "10", "count" => "15" }]
|
|
21
|
+
end
|
|
22
|
+
let(:zoekt_indices_state_query) { described_class::ZOEKT_INDICES_STATE_QUERY }
|
|
23
|
+
let(:zoekt_indices_state_query_results) do
|
|
24
|
+
[{ "state" => "0", "count" => "3" }, { "state" => "1", "count" => "7" }]
|
|
25
|
+
end
|
|
26
|
+
let(:zoekt_indices_watermark_query) { described_class::ZOEKT_INDICES_WATERMARK_QUERY }
|
|
27
|
+
let(:zoekt_indices_watermark_query_results) do
|
|
28
|
+
[{ "watermark_level" => "healthy", "count" => "8" }, { "watermark_level" => "warning", "count" => "2" }]
|
|
29
|
+
end
|
|
30
|
+
let(:zoekt_indices_storage_query) { described_class::ZOEKT_INDICES_STORAGE_QUERY }
|
|
31
|
+
let(:zoekt_indices_storage_query_results) do
|
|
32
|
+
[
|
|
33
|
+
{ "id" => "1", "reserved_storage_bytes" => "1000000", "used_storage_bytes" => "500000",
|
|
34
|
+
"node_name" => "zoekt-1" },
|
|
35
|
+
{ "id" => "2", "reserved_storage_bytes" => "2000000", "used_storage_bytes" => "1500000",
|
|
36
|
+
"node_name" => "zoekt-2" }
|
|
37
|
+
]
|
|
38
|
+
end
|
|
14
39
|
|
|
15
40
|
let(:zoekt_repository_schema_version_query_results) { [{ "count" => "1" }] }
|
|
16
41
|
|
|
@@ -50,7 +75,12 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
50
75
|
{
|
|
51
76
|
repositories_schema_version_query_result: zoekt_repositories_schema_version_query_results,
|
|
52
77
|
task_processing_query_result: zoekt_tasks_processing_query_results,
|
|
53
|
-
zoekt_nodes_status_query_result: zoekt_nodes_status_query_results
|
|
78
|
+
zoekt_nodes_status_query_result: zoekt_nodes_status_query_results,
|
|
79
|
+
node_storage_query_result: zoekt_node_storage_query_results,
|
|
80
|
+
repositories_state_query_result: zoekt_repositories_state_query_results,
|
|
81
|
+
indices_state_query_result: zoekt_indices_state_query_results,
|
|
82
|
+
indices_watermark_query_result: zoekt_indices_watermark_query_results,
|
|
83
|
+
indices_storage_query_result: zoekt_indices_storage_query_results
|
|
54
84
|
}
|
|
55
85
|
end
|
|
56
86
|
|
|
@@ -82,6 +112,16 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
82
112
|
.and_return(zoekt_repository_schema_version_query_results)
|
|
83
113
|
expect(connection).to receive(:exec_params).with(zoekt_nodes_status_query, [])
|
|
84
114
|
.and_return(zoekt_nodes_status_query_results)
|
|
115
|
+
expect(connection).to receive(:exec_params).with(zoekt_node_storage_query, [])
|
|
116
|
+
.and_return(zoekt_node_storage_query_results)
|
|
117
|
+
expect(connection).to receive(:exec_params).with(zoekt_repositories_state_query, [])
|
|
118
|
+
.and_return(zoekt_repositories_state_query_results)
|
|
119
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_state_query, [])
|
|
120
|
+
.and_return(zoekt_indices_state_query_results)
|
|
121
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_watermark_query, [])
|
|
122
|
+
.and_return(zoekt_indices_watermark_query_results)
|
|
123
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_storage_query, [])
|
|
124
|
+
.and_return(zoekt_indices_storage_query_results)
|
|
85
125
|
|
|
86
126
|
expect(collector.run).to eq(result)
|
|
87
127
|
end
|
|
@@ -94,6 +134,16 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
94
134
|
.and_raise(PG::UndefinedTable)
|
|
95
135
|
allow(connection).to receive(:exec_params).with(zoekt_nodes_status_query, [])
|
|
96
136
|
.and_raise(PG::UndefinedTable)
|
|
137
|
+
allow(connection).to receive(:exec_params).with(zoekt_node_storage_query, [])
|
|
138
|
+
.and_raise(PG::UndefinedTable)
|
|
139
|
+
allow(connection).to receive(:exec_params).with(zoekt_repositories_state_query, [])
|
|
140
|
+
.and_raise(PG::UndefinedTable)
|
|
141
|
+
allow(connection).to receive(:exec_params).with(zoekt_indices_state_query, [])
|
|
142
|
+
.and_raise(PG::UndefinedTable)
|
|
143
|
+
allow(connection).to receive(:exec_params).with(zoekt_indices_watermark_query, [])
|
|
144
|
+
.and_raise(PG::UndefinedTable)
|
|
145
|
+
allow(connection).to receive(:exec_params).with(zoekt_indices_storage_query, [])
|
|
146
|
+
.and_raise(PG::UndefinedTable)
|
|
97
147
|
|
|
98
148
|
expect(collector.run).to eq({})
|
|
99
149
|
end
|
|
@@ -108,6 +158,15 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
108
158
|
expect(connection).to receive(:exec_params).with(zoekt_repository_schema_version_query, %w[1 2302])
|
|
109
159
|
.and_raise(PG::UndefinedTable)
|
|
110
160
|
expect(connection).to receive(:exec_params).with(zoekt_nodes_status_query, []).and_raise(PG::UndefinedTable)
|
|
161
|
+
expect(connection).to receive(:exec_params).with(zoekt_node_storage_query, []).and_raise(PG::UndefinedColumn)
|
|
162
|
+
expect(connection).to receive(:exec_params).with(zoekt_repositories_state_query, [])
|
|
163
|
+
.and_raise(PG::UndefinedColumn)
|
|
164
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_state_query, [])
|
|
165
|
+
.and_raise(PG::UndefinedColumn)
|
|
166
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_watermark_query, [])
|
|
167
|
+
.and_raise(PG::UndefinedColumn)
|
|
168
|
+
expect(connection).to receive(:exec_params).with(zoekt_indices_storage_query, [])
|
|
169
|
+
.and_raise(PG::UndefinedColumn)
|
|
111
170
|
|
|
112
171
|
expect(collector.run).to eq({ task_processing_query_result: zoekt_tasks_processing_query_results })
|
|
113
172
|
end
|
|
@@ -143,6 +202,34 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
143
202
|
task_processing_query_result: [
|
|
144
203
|
{ "node_id" => "1", "node_name" => "zoekt-1", "task_count" => "5" },
|
|
145
204
|
{ "node_id" => "2", "node_name" => "zoekt-2", "task_count" => "10" }
|
|
205
|
+
],
|
|
206
|
+
node_storage_query_result: [
|
|
207
|
+
{
|
|
208
|
+
"id" => "1", "node_name" => "zoekt-1", "unclaimed_storage_bytes" => "1000000",
|
|
209
|
+
"storage_percent_used" => "0.75"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"id" => "2", "node_name" => "zoekt-2", "unclaimed_storage_bytes" => "2000000",
|
|
213
|
+
"storage_percent_used" => "0.50"
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
repositories_state_query_result: [
|
|
217
|
+
{ "state" => "0", "count" => "5" },
|
|
218
|
+
{ "state" => "10", "count" => "15" }
|
|
219
|
+
],
|
|
220
|
+
indices_state_query_result: [
|
|
221
|
+
{ "state" => "0", "count" => "3" },
|
|
222
|
+
{ "state" => "1", "count" => "7" }
|
|
223
|
+
],
|
|
224
|
+
indices_watermark_query_result: [
|
|
225
|
+
{ "watermark_level" => "healthy", "count" => "8" },
|
|
226
|
+
{ "watermark_level" => "warning", "count" => "2" }
|
|
227
|
+
],
|
|
228
|
+
indices_storage_query_result: [
|
|
229
|
+
{ "id" => "1", "reserved_storage_bytes" => "1000000", "used_storage_bytes" => "500000",
|
|
230
|
+
"node_name" => "zoekt-1" },
|
|
231
|
+
{ "id" => "2", "reserved_storage_bytes" => "2000000", "used_storage_bytes" => "1500000",
|
|
232
|
+
"node_name" => "zoekt-2" }
|
|
146
233
|
]
|
|
147
234
|
}
|
|
148
235
|
end
|
|
@@ -186,6 +273,67 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
186
273
|
)
|
|
187
274
|
end
|
|
188
275
|
|
|
276
|
+
data[:node_storage_query_result].each do |node_data|
|
|
277
|
+
expect(metrics).to receive(:add)
|
|
278
|
+
.with(
|
|
279
|
+
"search_zoekt_node_unclaimed_storage_bytes",
|
|
280
|
+
node_data["unclaimed_storage_bytes"].to_i,
|
|
281
|
+
zoekt_node_id: node_data["id"],
|
|
282
|
+
zoekt_node_name: node_data["node_name"]
|
|
283
|
+
)
|
|
284
|
+
expect(metrics).to receive(:add)
|
|
285
|
+
.with(
|
|
286
|
+
"search_zoekt_node_storage_percent_used",
|
|
287
|
+
node_data["storage_percent_used"].to_f,
|
|
288
|
+
zoekt_node_id: node_data["id"],
|
|
289
|
+
zoekt_node_name: node_data["node_name"]
|
|
290
|
+
)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
data[:repositories_state_query_result].each do |state_data|
|
|
294
|
+
expect(metrics).to receive(:add)
|
|
295
|
+
.with(
|
|
296
|
+
"search_zoekt_repositories_states_total",
|
|
297
|
+
state_data["count"].to_i,
|
|
298
|
+
state: state_data["state"]
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
data[:indices_state_query_result].each do |state_data|
|
|
303
|
+
expect(metrics).to receive(:add)
|
|
304
|
+
.with(
|
|
305
|
+
"search_zoekt_indices_states",
|
|
306
|
+
state_data["count"].to_i,
|
|
307
|
+
state: state_data["state"]
|
|
308
|
+
)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
data[:indices_watermark_query_result].each do |watermark_data|
|
|
312
|
+
expect(metrics).to receive(:add)
|
|
313
|
+
.with(
|
|
314
|
+
"search_zoekt_indices_watermark_levels",
|
|
315
|
+
watermark_data["count"].to_i,
|
|
316
|
+
watermark_level: watermark_data["watermark_level"]
|
|
317
|
+
)
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
data[:indices_storage_query_result].each do |storage_data|
|
|
321
|
+
expect(metrics).to receive(:add)
|
|
322
|
+
.with(
|
|
323
|
+
"search_zoekt_indices_reserved_storage_bytes",
|
|
324
|
+
storage_data["reserved_storage_bytes"].to_i,
|
|
325
|
+
zoekt_index_id: storage_data["id"],
|
|
326
|
+
zoekt_node_name: storage_data["node_name"]
|
|
327
|
+
)
|
|
328
|
+
expect(metrics).to receive(:add)
|
|
329
|
+
.with(
|
|
330
|
+
"search_zoekt_indices_used_storage_bytes",
|
|
331
|
+
storage_data["used_storage_bytes"].to_i,
|
|
332
|
+
zoekt_index_id: storage_data["id"],
|
|
333
|
+
zoekt_node_name: storage_data["node_name"]
|
|
334
|
+
)
|
|
335
|
+
end
|
|
336
|
+
|
|
189
337
|
probe_db
|
|
190
338
|
end
|
|
191
339
|
end
|