-
Notifications
You must be signed in to change notification settings - Fork 1
/
prometheus.yaml
461 lines (439 loc) · 13.1 KB
/
prometheus.yaml
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
---
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: prometheus
annotations:
openshift.io/display-name: Prometheus
tags: "quickstart,monitoring,prometheus,alerts"
template.openshift.io/bindable: "false"
description: Prometheus w/ Alerts deployment
labels:
template: prometheus
app: prometheus
parameters:
- description: The namespace to instantiate prometheus under.
name: NAMESPACE
required: true
- description: The location of the proxy image
name: IMAGE_PROXY
value: openshift/oauth-proxy:v1.0.0
- description: The location of the prometheus image
name: IMAGE_PROMETHEUS
value: openshift/prometheus:v2.5.0
- description: The location of the alertmanager image
name: IMAGE_ALERTMANAGER
value: openshift/prometheus-alertmanager:v0.9.1
- description: The location of alert-buffer image
name: IMAGE_ALERT_BUFFER
value: openshift/prometheus-alert-buffer:v0.0.2
- description: The session secret for the proxy
name: SESSION_SECRET
generate: expression
from: "[a-zA-Z0-9]{43}"
- desription: Jenkins user with access to monitoring
name: JENKINS_USER
required: true
- desription: Jenkins password for user with access to monitoring
name: JENKINS_PASS
required: true
- desription: Jenkins hostname to be monitored
name: JENKINS_HOST
required: true
- desription: Jenkins env name
name: ENV
required: true
objects:
- apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
annotations:
serviceaccounts.openshift.io/oauth-redirectreference.prom: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"prometheus"}}'
serviceaccounts.openshift.io/oauth-redirectreference.alerts: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"alerts"}}'
- apiVersion: authorization.openshift.io/v1
kind: RoleBinding
metadata:
name: prometheus-viewer
labels:
template: prometheus
app: prometheus
roleRef:
name: view
subjects:
- kind: ServiceAccount
name: prometheus
namespace: "${NAMESPACE}"
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: prometheus
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
spec:
to:
name: prometheus
port:
targetPort: prometheus-https
tls:
termination: Reencrypt
insecureEdgeTerminationPolicy: Redirect
- apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/scheme: https
service.alpha.openshift.io/serving-cert-secret-name: prometheus-tls
name: prometheus
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
spec:
ports:
- name: prometheus-https
port: 443
protocol: TCP
targetPort: 8443
- name: prometheus-http
port: 9090
protocol: TCP
targetPort: 9090
selector:
app: prometheus
- apiVersion: v1
kind: Secret
metadata:
name: prometheus-proxy
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
stringData:
session_secret: "${SESSION_SECRET}="
- apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: prometheus
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
spec:
updateStrategy:
type: RollingUpdate
podManagementPolicy: Parallel
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
name: prometheus
spec:
serviceAccountName: prometheus
containers:
- name: oauth-proxy
image: ${IMAGE_PROXY}
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: '50m'
memory: '100Mi'
limits:
cpu: "100m"
memory: "200Mi"
ports:
- containerPort: 8443
name: web
args:
- -provider=openshift
- -https-address=:8443
- -http-address=
- -email-domain=*
- -upstream=http://localhost:9090
- -client-id=system:serviceaccount:${NAMESPACE}:prometheus
- -openshift-ca=/etc/pki/tls/cert.pem
- -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}'
- -tls-cert=/etc/tls/private/tls.crt
- -tls-key=/etc/tls/private/tls.key
- -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
- -cookie-secret-file=/etc/proxy/secrets/session_secret
- -skip-auth-regex=^/metrics
volumeMounts:
- mountPath: /etc/tls/private
name: prometheus-tls
- mountPath: /etc/proxy/secrets
name: prometheus-secrets
- mountPath: /prometheus
name: prometheus-data
- name: prometheus
resources:
requests:
cpu: '200m'
memory: '512Mi'
limits:
cpu: "400m"
memory: "1024Mi"
ports:
- containerPort: 9090
name: prometheus
args:
- --storage.tsdb.retention=5d
- --storage.tsdb.min-block-duration=2m
- --config.file=/etc/prometheus/prometheus.yml
- --web.enable-lifecycle
image: ${IMAGE_PROMETHEUS}
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /etc/prometheus
name: prometheus-config
- mountPath: /prometheus
name: prometheus-data
- name: alerts-proxy
image: ${IMAGE_PROXY}
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "50m"
memory: "100Mi"
limits:
cpu: "100m"
memory: "200Mi"
ports:
- containerPort: 9443
name: web
args:
- -provider=openshift
- -https-address=:9443
- -http-address=
- -email-domain=*
- -upstream=http://localhost:9099
- -client-id=system:serviceaccount:${NAMESPACE}:prometheus
- -openshift-ca=/etc/pki/tls/cert.pem
- -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}'
- -tls-cert=/etc/tls/private/tls.crt
- -tls-key=/etc/tls/private/tls.key
- -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
- -cookie-secret-file=/etc/proxy/secrets/session_secret
- -skip-auth-regex=^/metrics
volumeMounts:
- mountPath: /etc/tls/private
name: alerts-tls
- mountPath: /etc/proxy/secrets
name: alerts-secrets
- name: alert-buffer
args:
- --storage-path=/alert-buffer/messages.db
image: ${IMAGE_ALERT_BUFFER}
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "50m"
memory: "100Mi"
limits:
cpu: "100m"
memory: "200Mi"
volumeMounts:
- mountPath: /alert-buffer
name: alert-buffer-data
ports:
- containerPort: 9099
name: alert-buf
- name: alertmanager
args:
- -config.file=/etc/alertmanager/alertmanager.yml
image: ${IMAGE_ALERTMANAGER}
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "100m"
memory: "100Mi"
limits:
cpu: "200m"
memory: "200Mi"
ports:
- containerPort: 9093
name: web
volumeMounts:
- mountPath: /etc/alertmanager
name: alertmanager-config
- mountPath: /alertmanager
name: alertmanager-data
restartPolicy: Always
volumes:
- name: prometheus-config
secret:
defaultMode: 420
secretName: prometheus-config
- name: prometheus-secrets
secret:
secretName: prometheus-proxy
- name: prometheus-tls
secret:
secretName: prometheus-tls
- name: prometheus-data
emptyDir: {}
- name: alertmanager-config
secret:
defaultMode: 420
secretName: prometheus-alerts
- name: alerts-secrets
secret:
secretName: alerts-proxy
- name: alerts-tls
secret:
secretName: prometheus-alerts-tls
- name: alertmanager-data
emptyDir: {}
- name: alert-buffer-data
emptyDir: {}
- apiVersion: v1
kind: Secret
metadata:
name: prometheus-config
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
stringData:
prometheus.rules: |
groups:
- name: jenkins-rules
interval: 30s # defaults to global interval
rules:
- alert: JenkinsDown
expr: up{job="jenkins"} == 0
for: 2m
annotations:
summary: "[${ENV}] Jenkins monitoring endpoind down"
description: "${ENV} Unable to scrape metrics from Jenkins"
- alert: HighCPU
expr: javamelody_system_cpu_load_pct > 30
for: 30m
annotations:
summary: "[${ENV}] High CPU usage on jenkins master"
description: "${ENV} jenkins has CPU usage over 30% for 30 minutes(current value: {{ $value }})"
- alert: HighMemoryUsage
expr: javamelody_memory_used_pct > 90
for: 10m
annotations:
summary: "[${ENV}] High memory usage on jenkins master"
description: "${ENV} jenkins has memory usage over 90% for 10 minutes(current value: {{ $value }})"
prometheus.yml: |
rule_files:
- 'prometheus.rules'
# A scrape configuration for running Prometheus on a Kubernetes cluster.
# This uses separate scrape configs for cluster components (i.e. API server, node)
# and services to allow each to use different authentication configs.
#
# Kubernetes labels will be added as Prometheus labels on metrics via the
# `labelmap` relabeling action.
# Scrape config for API servers.
#
# Kubernetes exposes API servers as endpoints to the default/kubernetes
# service so this uses `endpoints` role and uses relabelling to only keep
# the endpoints associated with the default/kubernetes service using the
# default named port `https`. This works for single API server deployments as
# well as HA API server deployments.
scrape_configs:
- job_name: 'jenkins'
scheme: https
metrics_path: '/monitoring'
tls_config:
ca_file: /etc/pki/tls/redhat/ca.crt
basic_auth:
username: ${JENKINS_USER}
password: ${JENKINS_PASS}
params:
format: ['prometheus']
scrape_interval: 30s
static_configs:
- targets: ['${JENKINS_HOST}']
labels:
env: '${ENV}'
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
alerting:
alertmanagers:
- scheme: http
static_configs:
- targets:
- "localhost:9093"
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: alerts
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
spec:
to:
name: alerts
tls:
termination: Reencrypt
insecureEdgeTerminationPolicy: Redirect
- apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.openshift.io/serving-cert-secret-name: prometheus-alerts-tls
labels:
name: alerts
template: prometheus
app: prometheus
name: alerts
namespace: "${NAMESPACE}"
spec:
ports:
- name: alerts
port: 443
protocol: TCP
targetPort: 9443
selector:
app: prometheus
- apiVersion: v1
kind: Secret
metadata:
name: alerts-proxy
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
stringData:
session_secret: "${SESSION_SECRET}="
- apiVersion: v1
kind: Secret
metadata:
name: prometheus-alerts
namespace: "${NAMESPACE}"
labels:
template: prometheus
app: prometheus
stringData:
alertmanager.yml: |
global:
smtp_smarthost: <mail-host>
smtp_from: [email protected]
smtp_require_tls: true
route:
receiver: alert-email
repeat_interval: 3h
group_by: []
receivers:
- name: alert-email
email_configs:
- to: [email protected]
send_resolved: true