-
Notifications
You must be signed in to change notification settings - Fork 243
/
collectors.go
331 lines (300 loc) · 11.2 KB
/
collectors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
package controller
import "github.com/prometheus/client_golang/prometheus"
var (
defaultLabels = []string{"project", "topics", "kind", "ref", "variables"}
jobLabels = []string{"stage", "job_name", "runner_description"}
statusLabels = []string{"status"}
environmentLabels = []string{"project", "environment"}
environmentInformationLabels = []string{"environment_id", "external_url", "kind", "ref", "latest_commit_short_id", "current_commit_short_id", "available", "username"}
statusesList = [...]string{"created", "waiting_for_resource", "preparing", "pending", "running", "success", "failed", "canceled", "skipped", "manual", "scheduled"}
)
// NewInternalCollectorCurrentlyQueuedTasksCount returns a new collector for the gcpe_currently_queued_tasks_count metric
func NewInternalCollectorCurrentlyQueuedTasksCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_currently_queued_tasks_count",
Help: "Number of tasks in the queue",
},
[]string{},
)
}
// NewInternalCollectorEnvironmentsCount returns a new collector for the gcpe_environments_count metric
func NewInternalCollectorEnvironmentsCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_environments_count",
Help: "Number of GitLab environments being exported",
},
[]string{},
)
}
// NewInternalCollectorExecutedTasksCount returns a new collector for the gcpe_executed_tasks_count metric
func NewInternalCollectorExecutedTasksCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_executed_tasks_count",
Help: "Number of tasks executed",
},
[]string{},
)
}
// NewInternalCollectorGitLabAPIRequestsCount returns a new collector for the gcpe_gitlab_api_requests_count metric
func NewInternalCollectorGitLabAPIRequestsCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_gitlab_api_requests_count",
Help: "GitLab API requests count",
},
[]string{},
)
}
// NewInternalCollectorMetricsCount returns a new collector for the gcpe_metrics_count metric
func NewInternalCollectorMetricsCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_metrics_count",
Help: "Number of GitLab pipelines metrics being exported",
},
[]string{},
)
}
// NewInternalCollectorProjectsCount returns a new collector for the gcpe_projects_count metric
func NewInternalCollectorProjectsCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_projects_count",
Help: "Number of GitLab projects being exported",
},
[]string{},
)
}
// NewInternalCollectorRefsCount returns a new collector for the gcpe_refs_count metric
func NewInternalCollectorRefsCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gcpe_refs_count",
Help: "Number of GitLab refs being exported",
},
[]string{},
)
}
// NewCollectorCoverage returns a new collector for the gitlab_ci_pipeline_coverage metric
func NewCollectorCoverage() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_coverage",
Help: "Coverage of the most recent pipeline",
},
defaultLabels,
)
}
// NewCollectorDurationSeconds returns a new collector for the gitlab_ci_pipeline_duration_seconds metric
func NewCollectorDurationSeconds() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_duration_seconds",
Help: "Duration in seconds of the most recent pipeline",
},
defaultLabels,
)
}
// NewCollectorQueuedDurationSeconds returns a new collector for the gitlab_ci_pipeline_queued_duration_seconds metric
func NewCollectorQueuedDurationSeconds() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_queued_duration_seconds",
Help: "Duration in seconds the most recent pipeline has been queued before starting",
},
defaultLabels,
)
}
// NewCollectorEnvironmentBehindCommitsCount returns a new collector for the gitlab_ci_environment_behind_commits_count metric
func NewCollectorEnvironmentBehindCommitsCount() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_behind_commits_count",
Help: "Number of commits the environment is behind given its last deployment",
},
environmentLabels,
)
}
// NewCollectorEnvironmentBehindDurationSeconds returns a new collector for the gitlab_ci_environment_behind_duration_seconds metric
func NewCollectorEnvironmentBehindDurationSeconds() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_behind_duration_seconds",
Help: "Duration in seconds the environment is behind the most recent commit given its last deployment",
},
environmentLabels,
)
}
// NewCollectorEnvironmentDeploymentCount returns a new collector for the gitlab_ci_environment_deployment_count metric
func NewCollectorEnvironmentDeploymentCount() prometheus.Collector {
return prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gitlab_ci_environment_deployment_count",
Help: "Number of deployments for an environment",
},
environmentLabels,
)
}
// NewCollectorEnvironmentDeploymentDurationSeconds returns a new collector for the gitlab_ci_environment_deployment_duration_seconds metric
func NewCollectorEnvironmentDeploymentDurationSeconds() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_deployment_duration_seconds",
Help: "Duration in seconds of the most recent deployment of the environment",
},
environmentLabels,
)
}
// NewCollectorEnvironmentDeploymentJobID returns a new collector for the gitlab_ci_environment_deployment_id metric
func NewCollectorEnvironmentDeploymentJobID() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_deployment_job_id",
Help: "ID of the most recent deployment job of the environment",
},
environmentLabels,
)
}
// NewCollectorEnvironmentDeploymentStatus returns a new collector for the gitlab_ci_environment_deployment_status metric
func NewCollectorEnvironmentDeploymentStatus() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_deployment_status",
Help: "Status of the most recent deployment of the environment",
},
append(environmentLabels, "status"),
)
}
// NewCollectorEnvironmentDeploymentTimestamp returns a new collector for the gitlab_ci_environment_deployment_timestamp metric
func NewCollectorEnvironmentDeploymentTimestamp() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_deployment_timestamp",
Help: "Creation date of the most recent deployment of the environment",
},
environmentLabels,
)
}
// NewCollectorEnvironmentInformation returns a new collector for the gitlab_ci_environment_information metric
func NewCollectorEnvironmentInformation() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_environment_information",
Help: "Information about the environment",
},
append(environmentLabels, environmentInformationLabels...),
)
}
// NewCollectorID returns a new collector for the gitlab_ci_pipeline_id metric
func NewCollectorID() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_id",
Help: "ID of the most recent pipeline",
},
defaultLabels,
)
}
// NewCollectorJobArtifactSizeBytes returns a new collector for the gitlab_ci_pipeline_job_artifact_size_bytes metric
func NewCollectorJobArtifactSizeBytes() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_job_artifact_size_bytes",
Help: "Artifact size in bytes (sum of all of them) of the most recent job",
},
append(defaultLabels, jobLabels...),
)
}
// NewCollectorJobDurationSeconds returns a new collector for the gitlab_ci_pipeline_job_duration_seconds metric
func NewCollectorJobDurationSeconds() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_job_duration_seconds",
Help: "Duration in seconds of the most recent job",
},
append(defaultLabels, jobLabels...),
)
}
// NewCollectorJobID returns a new collector for the gitlab_ci_pipeline_job_id metric
func NewCollectorJobID() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_job_id",
Help: "ID of the most recent job",
},
append(defaultLabels, jobLabels...),
)
}
// NewCollectorJobQueuedDurationSeconds returns a new collector for the gitlab_ci_pipeline_job_queued_duration_seconds metric
func NewCollectorJobQueuedDurationSeconds() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_job_queued_duration_seconds",
Help: "Duration in seconds the most recent job has been queued before starting",
},
append(defaultLabels, jobLabels...),
)
}
// NewCollectorJobRunCount returns a new collector for the gitlab_ci_pipeline_job_run_count metric
func NewCollectorJobRunCount() prometheus.Collector {
return prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gitlab_ci_pipeline_job_run_count",
Help: "Number of executions of a job",
},
append(defaultLabels, jobLabels...),
)
}
// NewCollectorJobStatus returns a new collector for the gitlab_ci_pipeline_job_status metric
func NewCollectorJobStatus() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_job_status",
Help: "Status of the most recent job",
},
append(defaultLabels, append(jobLabels, statusLabels...)...),
)
}
// NewCollectorJobTimestamp returns a new collector for the gitlab_ci_pipeline_job_timestamp metric
func NewCollectorJobTimestamp() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_job_timestamp",
Help: "Creation date timestamp of the the most recent job",
},
append(defaultLabels, jobLabels...),
)
}
// NewCollectorStatus returns a new collector for the gitlab_ci_pipeline_status metric
func NewCollectorStatus() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_status",
Help: "Status of the most recent pipeline",
},
append(defaultLabels, "status"),
)
}
// NewCollectorTimestamp returns a new collector for the gitlab_ci_pipeline_timestamp metric
func NewCollectorTimestamp() prometheus.Collector {
return prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gitlab_ci_pipeline_timestamp",
Help: "Timestamp of the last update of the most recent pipeline",
},
defaultLabels,
)
}
// NewCollectorRunCount returns a new collector for the gitlab_ci_pipeline_run_count metric
func NewCollectorRunCount() prometheus.Collector {
return prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gitlab_ci_pipeline_run_count",
Help: "Number of executions of a pipeline",
},
defaultLabels,
)
}