gitlab-exporter 16.5.0 → 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 +132 -1
- data/lib/gitlab_exporter/version.rb +1 -1
- data/spec/database/zoekt_spec.rb +112 -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
|
@@ -71,6 +71,30 @@ module GitLab
|
|
|
71
71
|
FROM zoekt_nodes
|
|
72
72
|
SQL
|
|
73
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
|
+
|
|
74
98
|
def run
|
|
75
99
|
return {} unless zoekt_indexing_enabled?
|
|
76
100
|
|
|
@@ -78,7 +102,11 @@ module GitLab
|
|
|
78
102
|
task_processing_query_result: execute(ZOEKT_TASKS_PROCESSING_QUERY, [Time.now.utc]),
|
|
79
103
|
repositories_schema_version_query_result: repositories_schema_version_query_result,
|
|
80
104
|
zoekt_nodes_status_query_result: execute(ZOEKT_NODES_STATUS_QUERY),
|
|
81
|
-
node_storage_query_result: execute(ZOEKT_NODE_STORAGE_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)
|
|
82
110
|
}.compact
|
|
83
111
|
end
|
|
84
112
|
|
|
@@ -141,6 +169,7 @@ module GitLab
|
|
|
141
169
|
end
|
|
142
170
|
|
|
143
171
|
# The prober which is called when gathering metrics
|
|
172
|
+
# rubocop:disable Metrics/ClassLength
|
|
144
173
|
class ZoektProber
|
|
145
174
|
PrometheusMetrics.describe(
|
|
146
175
|
"search_zoekt_task_processing_queue_size",
|
|
@@ -172,6 +201,36 @@ module GitLab
|
|
|
172
201
|
"gauge"
|
|
173
202
|
)
|
|
174
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
|
+
|
|
175
234
|
def initialize(metrics: PrometheusMetrics.new, **opts)
|
|
176
235
|
@metrics = metrics
|
|
177
236
|
@collector = opts[:collector] || ZoektCollector.new(**opts)
|
|
@@ -192,6 +251,10 @@ module GitLab
|
|
|
192
251
|
process_repository_results(results[:repositories_schema_version_query_result])
|
|
193
252
|
process_node_status_results(results[:zoekt_nodes_status_query_result])
|
|
194
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])
|
|
195
258
|
end
|
|
196
259
|
|
|
197
260
|
def process_task_results(results)
|
|
@@ -213,6 +276,22 @@ module GitLab
|
|
|
213
276
|
end
|
|
214
277
|
end
|
|
215
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
|
+
|
|
216
295
|
def add_processing_zoekt_tasks_to_metric(row)
|
|
217
296
|
@metrics.add(
|
|
218
297
|
"search_zoekt_task_processing_queue_size",
|
|
@@ -269,10 +348,62 @@ module GitLab
|
|
|
269
348
|
)
|
|
270
349
|
end
|
|
271
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
|
+
|
|
272
402
|
def write_to(target)
|
|
273
403
|
target.write(@metrics.to_s)
|
|
274
404
|
end
|
|
275
405
|
end
|
|
406
|
+
# rubocop:enable Metrics/ClassLength
|
|
276
407
|
end
|
|
277
408
|
end
|
|
278
409
|
end
|
data/spec/database/zoekt_spec.rb
CHANGED
|
@@ -15,6 +15,27 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
15
15
|
let(:zoekt_node_storage_query_results) do
|
|
16
16
|
[{ "id" => "1", "node_name" => "foo", "unclaimed_storage_bytes" => "1000000", "storage_percent_used" => "0.75" }]
|
|
17
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
|
|
18
39
|
|
|
19
40
|
let(:zoekt_repository_schema_version_query_results) { [{ "count" => "1" }] }
|
|
20
41
|
|
|
@@ -55,7 +76,11 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
55
76
|
repositories_schema_version_query_result: zoekt_repositories_schema_version_query_results,
|
|
56
77
|
task_processing_query_result: zoekt_tasks_processing_query_results,
|
|
57
78
|
zoekt_nodes_status_query_result: zoekt_nodes_status_query_results,
|
|
58
|
-
node_storage_query_result: zoekt_node_storage_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
|
|
59
84
|
}
|
|
60
85
|
end
|
|
61
86
|
|
|
@@ -89,6 +114,14 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
89
114
|
.and_return(zoekt_nodes_status_query_results)
|
|
90
115
|
expect(connection).to receive(:exec_params).with(zoekt_node_storage_query, [])
|
|
91
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)
|
|
92
125
|
|
|
93
126
|
expect(collector.run).to eq(result)
|
|
94
127
|
end
|
|
@@ -103,6 +136,14 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
103
136
|
.and_raise(PG::UndefinedTable)
|
|
104
137
|
allow(connection).to receive(:exec_params).with(zoekt_node_storage_query, [])
|
|
105
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)
|
|
106
147
|
|
|
107
148
|
expect(collector.run).to eq({})
|
|
108
149
|
end
|
|
@@ -118,6 +159,14 @@ describe GitLab::Exporter::Database::ZoektCollector do
|
|
|
118
159
|
.and_raise(PG::UndefinedTable)
|
|
119
160
|
expect(connection).to receive(:exec_params).with(zoekt_nodes_status_query, []).and_raise(PG::UndefinedTable)
|
|
120
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)
|
|
121
170
|
|
|
122
171
|
expect(collector.run).to eq({ task_processing_query_result: zoekt_tasks_processing_query_results })
|
|
123
172
|
end
|
|
@@ -163,6 +212,24 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
163
212
|
"id" => "2", "node_name" => "zoekt-2", "unclaimed_storage_bytes" => "2000000",
|
|
164
213
|
"storage_percent_used" => "0.50"
|
|
165
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" }
|
|
166
233
|
]
|
|
167
234
|
}
|
|
168
235
|
end
|
|
@@ -223,6 +290,50 @@ describe GitLab::Exporter::Database::ZoektProber do
|
|
|
223
290
|
)
|
|
224
291
|
end
|
|
225
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
|
+
|
|
226
337
|
probe_db
|
|
227
338
|
end
|
|
228
339
|
end
|