-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitoring-logs-elasticsearch.yaml
461 lines (455 loc) · 11.2 KB
/
monitoring-logs-elasticsearch.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: v1
kind: Namespace
metadata:
name: knative-monitoring
---
apiVersion: v1
kind: Service
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: elasticsearch-logging
kubernetes.io/cluster-service: "true"
kubernetes.io/name: Elasticsearch
name: elasticsearch-logging
namespace: knative-monitoring
spec:
ports:
- port: 9200
protocol: TCP
targetPort: db
selector:
app: elasticsearch-logging
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: elasticsearch-logging
kubernetes.io/cluster-service: "true"
name: elasticsearch-logging
namespace: knative-monitoring
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: elasticsearch-logging
kubernetes.io/cluster-service: "true"
name: elasticsearch-logging
rules:
- apiGroups:
- ""
resources:
- services
- namespaces
- endpoints
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: elasticsearch-logging
kubernetes.io/cluster-service: "true"
name: elasticsearch-logging
namespace: knative-monitoring
roleRef:
apiGroup: ""
kind: ClusterRole
name: elasticsearch-logging
subjects:
- apiGroup: ""
kind: ServiceAccount
name: elasticsearch-logging
namespace: knative-monitoring
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: elasticsearch-logging
kubernetes.io/cluster-service: "true"
version: v5.6.4
name: elasticsearch-logging
namespace: knative-monitoring
spec:
replicas: 2
selector:
matchLabels:
app: elasticsearch-logging
version: v5.6.4
serviceName: elasticsearch-logging
template:
metadata:
labels:
app: elasticsearch-logging
kubernetes.io/cluster-service: "true"
version: v5.6.4
spec:
containers:
- env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: k8s.gcr.io/elasticsearch:v5.6.4
name: elasticsearch-logging
ports:
- containerPort: 9200
name: db
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
resources:
limits:
cpu: 1000m
requests:
cpu: 100m
volumeMounts:
- mountPath: /data
name: elasticsearch-logging
initContainers:
- command:
- /sbin/sysctl
- -w
- vm.max_map_count=262144
image: alpine:3.6
name: elasticsearch-logging-init
securityContext:
privileged: true
serviceAccountName: elasticsearch-logging
volumes:
- emptyDir: {}
name: elasticsearch-logging
---
apiVersion: v1
kind: Service
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: kibana-logging
kubernetes.io/cluster-service: "true"
kubernetes.io/name: Kibana
name: kibana-logging
namespace: knative-monitoring
spec:
ports:
- port: 5601
protocol: TCP
targetPort: ui
selector:
app: kibana-logging
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: kibana-logging
kubernetes.io/cluster-service: "true"
name: kibana-logging
namespace: knative-monitoring
spec:
replicas: 1
selector:
matchLabels:
app: kibana-logging
template:
metadata:
labels:
app: kibana-logging
spec:
containers:
- env:
- name: ELASTICSEARCH_URL
value: http://elasticsearch-logging.knative-monitoring.svc.cluster.local:9200
- name: SERVER_BASEPATH
value: /api/v1/namespaces/knative-monitoring/services/kibana-logging/proxy
- name: XPACK_MONITORING_ENABLED
value: "false"
- name: XPACK_SECURITY_ENABLED
value: "false"
image: docker.elastic.co/kibana/kibana:5.6.4
name: kibana-logging
ports:
- containerPort: 5601
name: ui
protocol: TCP
resources:
limits:
cpu: 1000m
requests:
cpu: 100m
---
apiVersion: v1
data:
100.system.conf: |-
<system>
root_dir /tmp/fluentd-buffers/
</system>
200.containers.input.conf: |-
<source>
@id fluentd-containers.log
@type tail
path /var/log/containers/*user-container-*.log,/var/log/containers/*build-step-*.log,/var/log/containers/controller-*controller-*.log,/var/log/containers/webhook-*webhook-*.log,/var/log/containers/*autoscaler-*autoscaler-*.log,/var/log/containers/*queue-proxy-*.log,/var/log/containers/activator-*activator-*.log
pos_file /var/log/es-containers.log.pos
time_format %Y-%m-%dT%H:%M:%S.%NZ
tag raw.kubernetes.*
format json
read_from_head true
</source>
# Combine multi line logs which form an exception stack trace into a single log entry
<match raw.kubernetes.**>
@id raw.kubernetes
@type detect_exceptions
remove_tag_prefix raw
message log
stream stream
multiline_flush_interval 5
max_bytes 500000
max_lines 1000
</match>
# Add Kubernetes metadata
<filter kubernetes.**>
@type kubernetes_metadata
</filter>
300.forward.input.conf: |-
# Takes the messages sent over TCP, e.g. request logs from Istio
<source>
@type forward
port 24224
</source>
900.output.conf: |-
# Send to Elastic Search
<match **>
@id elasticsearch
@type elasticsearch
@log_level info
include_tag_key true
host elasticsearch-logging.knative-monitoring.svc.cluster.local
port 9200
logstash_format true
<buffer>
@type file
path /var/log/fluentd-buffers/kubernetes.system.buffer
flush_mode interval
retry_type exponential_backoff
flush_thread_count 2
flush_interval 5s
retry_forever
retry_max_interval 30
chunk_limit_size 2M
queue_limit_length 8
overflow_action block
</buffer>
</match>
kind: ConfigMap
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
name: fluentd-ds-config
namespace: knative-monitoring
---
apiVersion: config.istio.io/v1alpha2
kind: logentry
metadata:
name: requestlog
namespace: istio-system
spec:
monitored_resource_type: '"UNSPECIFIED"'
severity: '"Info"'
timestamp: request.time
variables:
destinationConfiguration: destination.labels["serving.knative.dev/configuration"]
| "unknown"
destinationK8sService: destination.service | ""
destinationNamespace: destination.namespace | ""
destinationRevision: destination.labels["serving.knative.dev/revision"] | "unknown"
destinationService: destination.labels["serving.knative.dev/service"] | "unknown"
latency: response.duration | "0ms"
method: request.method | ""
protocol: request.scheme | "http"
referer: request.referer | "unknown"
requestHost: request.host | ""
requestSize: request.size | 0
responseCode: response.code | 0
responseSize: response.size | 0
sourceK8sService: source.service | "unknown"
sourceNamespace: source.namespace | "unknown"
traceId: request.headers["x-b3-traceid"] | "unknown"
url: request.path | ""
userAgent: request.useragent | "unknown"
---
apiVersion: config.istio.io/v1alpha2
kind: fluentd
metadata:
name: requestloghandler
namespace: istio-system
spec:
address: fluentd-ds.knative-monitoring:24224
---
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
name: requestlogtofluentd
namespace: istio-system
spec:
actions:
- handler: requestloghandler.fluentd
instances:
- requestlog.logentry
match: context.protocol == "http" || context.protocol == "grpc"
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: fluentd-ds
kubernetes.io/cluster-service: "true"
name: fluentd-ds
namespace: knative-monitoring
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: fluentd-ds
kubernetes.io/cluster-service: "true"
name: fluentd-ds
rules:
- apiGroups:
- ""
resources:
- namespaces
- pods
verbs:
- get
- watch
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: fluentd-ds
kubernetes.io/cluster-service: "true"
name: fluentd-ds
roleRef:
apiGroup: ""
kind: ClusterRole
name: fluentd-ds
subjects:
- apiGroup: ""
kind: ServiceAccount
name: fluentd-ds
namespace: knative-monitoring
---
apiVersion: v1
kind: Service
metadata:
labels:
app: fluentd-ds
name: fluentd-ds
namespace: knative-monitoring
spec:
ports:
- name: fluentd-tcp
port: 24224
protocol: TCP
targetPort: 24224
- name: fluentd-udp
port: 24224
protocol: UDP
targetPort: 24224
selector:
app: fluentd-ds
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: fluentd-ds
kubernetes.io/cluster-service: "true"
version: v2.0.4
name: fluentd-ds
namespace: knative-monitoring
spec:
selector:
matchLabels:
app: fluentd-ds
version: v2.0.4
template:
metadata:
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ""
labels:
app: fluentd-ds
kubernetes.io/cluster-service: "true"
version: v2.0.4
spec:
containers:
- env:
- name: FLUENTD_ARGS
value: --no-supervisor -q
image: k8s.gcr.io/fluentd-elasticsearch:v2.0.4
name: fluentd-ds
resources:
limits:
memory: 500Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- mountPath: /var/log/containers
name: varlogcontainers
readOnly: true
- mountPath: /var/log/pods
name: varlogpods
readOnly: true
- mountPath: /var/lib/docker/containers
name: varlibdockercontainers
readOnly: true
- mountPath: /host/lib
name: libsystemddir
readOnly: true
- mountPath: /var/data/cripersistentstorage
name: persistentstorage
readOnly: true
- mountPath: /etc/fluent/config.d
name: config-volume
nodeSelector:
beta.kubernetes.io/fluentd-ds-ready: "true"
serviceAccountName: fluentd-ds
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /var/log/containers
name: varlogcontainers
- hostPath:
path: /var/log/pods
name: varlogpods
- hostPath:
path: /var/lib/docker/containers
name: varlibdockercontainers
- hostPath:
path: /usr/lib64
name: libsystemddir
- hostPath:
path: /var/data/cripersistentstorage
name: persistentstorage
- configMap:
name: fluentd-ds-config
name: config-volume
---