This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluent.conf
327 lines (283 loc) · 7.19 KB
/
fluent.conf
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
<system>
log_level warn
</system>
<source>
@type prometheus
bind 0.0.0.0
port 9000
metrics_path /metrics
</source>
<source>
@type prometheus_monitor
</source>
<source>
@type tail
path /var/log/containers/*.log
pos_file "#{ENV['FLUENTD_CONTAINERS_POS_FILE']}"
time_format %Y-%m-%dT%H:%M:%S.%NZ
tag kubernetes.*
format json
read_from_head true
</source>
# Drop empty / only whitespace messages
<filter kubernetes.**>
@type ignore
@id ignore_empty
regexp1 log \A\s*\z
</filter>
<source>
@type systemd
@id systemd
tag systemd
path /var/log/journal
read_from_head true
<storage>
@type local
path "#{ENV['FLUENTD_JOURNAL_POS_FILE']}"
</storage>
<entry>
fields_strip_underscores true
fields_lowercase true
</entry>
</source>
<filter systemd>
@type nais_remap_journald
</filter>
# Rewrite tag from systemd to include program
<match systemd>
@type rewrite_tag_filter
<rule>
key program
pattern /(.+)/
tag systemd.$1
</rule>
</match>
<filter systemd.kubelet>
@type nais_logformat
field message
logformat glog
</filter>
<filter systemd.dockerd>
@type nais_logformat
field message
logformat logrus
</filter>
<filter systemd.kube-proxy>
@type nais_logformat
field message
logformat glog
</filter>
<filter systemd.update_engine>
@type nais_logformat
field message
logformat glog
</filter>
<filter systemd.**>
@type nais_prefix_fields
prefix x_
regex ^(?:namespace|type)$
</filter>
# Rewrite tag from throttle filter log so it's not dropped
<match fluent.**>
@type rewrite_tag_filter
<rule>
key message
pattern /^log throttle:/
tag nais.throttle.warning
</rule>
</match>
<match fluent.**>
@type null
@id fluent_drop
</match>
<match kubernetes.var.log.containers.**nais-logd-fluentd**>
@type null
@id logd_drop
</match>
<filter kubernetes.**>
@type kubernetes_metadata
annotation_match ^nais.io
</filter>
# Rewrite tag on system namespaces to bypass throttle filter
<match kubernetes.**>
@type rewrite_tag_filter
<rule>
key $['kubernetes']['namespace_name']
pattern /^(?:kube-system|nais|rook-ceph|reboot-coordinator|vault)$/
tag nais.${tag}
</rule>
<rule>
key $['kubernetes']['namespace_name']
pattern /.*/
tag throttle.${tag}
</rule>
</match>
<filter throttle.**>
@type throttle
group_key ["kubernetes.namespace_name", "kubernetes.pod_name", "kubernetes.container_name"]
group_bucket_period_s "#{ENV['THROTTLE_BUCKET_PERIOD']}"
group_bucket_limit "#{ENV['THROTTLE_BUCKET_LIMIT']}"
group_reset_rate_s "#{ENV['THROTTLE_RESET_RATE']}"
group_drop_logs "#{ENV['THROTTLE_DROP_LOGS']}"
</filter>
<filter {nais.**,throttle.**}>
@type nais_merge_json
field log
</filter>
<filter **.var.log.containers.csi-rbdplugin-**>
@type nais_logformat
logformat glog
</filter>
<filter **.var.log.containers.rook-discover-**>
@type nais_logformat
logformat rook
</filter>
<filter **.var.log.containers.rook-ceph-osd-**>
@type nais_logformat
logformat rook
</filter>
<filter **.var.log.containers.rook-ceph-operator-**>
@type nais_logformat
logformat rook,glog
</filter>
<filter **.var.log.containers.rfr-**>
@type nais_logformat
logformat redis
</filter>
<filter **.var.log.containers.rfs-**>
@type nais_logformat
logformat redis
</filter>
<filter {nais.**,throttle.**}>
@type nais_logformat
</filter>
<filter {nais.**,throttle.**}>
@type nais_logtransform
</filter>
<filter {nais.**,throttle.**}>
@type nais_prefix_fields
prefix x_
regex ^(?:category|container|host|namespace|application|pod|team|type)$
</filter>
<filter {nais.**,throttle.**}>
@type nais_remap_kubernetes
labels team
</filter>
<filter **.var.log.containers.**kubewatch**>
@type nais_kubewatch
type_field x_type
</filter>
<filter **.var.log.containers.**kube-apiserver**>
@type nais_kubeapiserver
</filter>
<filter **.var.log.containers.**traefik-ingress-controller**>
@type nais_remap_traefik
</filter>
<filter **>
@type nais_remap_elasticsearch
</filter>
<filter **>
@type nais_remap_java
</filter>
<filter {nais.**,throttle.**}>
@type nais_keywords
field exception
regex \b[A-Z]\w+Exception\b
</filter>
<filter {nais.**,throttle.**}>
@type nais_keywords
field message_code
regex \bORA-\d{5}\b
</filter>
<filter {nais.**,throttle.**}>
@type nais_drop_nested_elements
</filter>
<filter {nais.**,throttle.**}>
@type record_transformer
<record>
type "containerlog"
cluster "#{ENV['CLUSTER_NAME']}"
envclass "#{ENV['CLUSTER_ENVCLASS']}"
</record>
</filter>
<filter systemd**>
@type record_transformer
<record>
type "journal"
cluster "#{ENV['CLUSTER_NAME']}"
envclass "#{ENV['CLUSTER_ENVCLASS']}"
</record>
</filter>
<filter **>
@type nais_prefix_fields
prefix x_
regex ^(?!(?:[xX][-_]|@timestamp$|@version$|type$|received_at$|message$|message_code$|container$|host$|namespace$|application$|pod$|thread$|component$|category$|level$|stack_trace$|exception$|cluster$|envclass$|content_length$|referer$|remote_ip$|remote_port$|response_code$|request$|user$|user_agent$|ident$|facility$|severity$|program$|processing_time$|source$|event$|uri$|method$|operation$|session$|path$|query_params$|team$|transaction$)).*
</filter>
# use empty string for fields missing in log message
<filter **>
@type record_transformer
enable_ruby
<record>
tmp_program ${record.has_key?('program') ? record['program'] : ''}
tmp_level ${record.has_key?('level') ? record['level'] : ''}
tmp_pod ${record.has_key?('pod') ? record['pod'] : ''}
tmp_team ${record.has_key?('team') ? record['team'] : ''}
tmp_namespace ${record.has_key?('namespace') ? record['namespace'] : ''}
tmp_application ${record.has_key?('application') ? record['application'] : ''}
</record>
</filter>
<filter **>
@type prometheus
<metric>
name logd_messages_total
type counter
desc Number of log messages
</metric>
<metric>
name logd_exceptions_total
type counter
desc Number of exceptions
label_key exception
</metric>
<labels>
log_program ${tmp_program}
log_level ${tmp_level}
log_pod_name ${tmp_pod}
log_team ${tmp_team}
log_namespace ${tmp_namespace}
log_app ${tmp_application}
</labels>
</filter>
<filter **>
@type record_transformer
remove_keys tmp_program,tmp_level,tmp_pod,tmp_team,tmp_namespace,tmp_application
</filter>
<match **>
@type elasticsearch
@id elasticsearch_output
include_tag_key false
hosts "#{ENV['ELASTICSEARCH_HOSTS']}"
scheme "#{ENV['ELASTICSEARCH_SCHEME']}"
ssl_verify "#{ENV['ELASTICSEARCH_SSL_VERIFY']}"
ca_file "#{ENV['ELASTICSEARCH_CA_FILE']}"
type_name "#{ENV['ELASTICSEARCH_TYPE_NAME']}"
index_name "#{ENV['ELASTICSEARCH_INDEX_NAME']}"
logstash_format "#{ENV['ELASTICSEARCH_LOGSTASH_FORMAT']}"
logstash_prefix "#{ENV['ELASTICSEARCH_LOGSTASH_PREFIX']}"
reconnect_on_error true
reload_connections false
reload_on_failure false
<buffer>
flush_mode interval
flush_interval 5
flush_thread_count 8
retry_wait 5
retry_type exponential_backoff
retry_exponential_backoff_base 2
retry_forever false
retry_max_times "#{ENV['ELASTICSEARCH_MAX_RETRIES']}"
chunk_limit_size 4M
chunk_limit_records 4096
disable_chunk_backup true
</buffer>
</match>