-
Notifications
You must be signed in to change notification settings - Fork 3
/
google-fluentd-sidecar.conf
68 lines (55 loc) · 2.08 KB
/
google-fluentd-sidecar.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
@include config.d/*.conf
# Do not collect fluentd's own logs to avoid infinite loops.
<match fluent.**>
@type null
</match>
# Add k8s_container label from environment variables K8S_NAMESPACE, K8S_POD, K8S_CONTAINER
<filter **>
@type record_transformer
enable_ruby true
<record>
"logging.googleapis.com/local_resource_id" ${"k8s_container.#{ENV['K8S_NAMESPACE']}.#{ENV['K8S_POD']}.#{ENV['K8S_CONTAINER']}"}
</record>
</filter>
# Add Kubernetes metadata labels from DownwardApiVolume /k8s/labels
# This enables searching/aggregating logs using k8s labels.
<filter **>
@type record_transformer
enable_ruby true
<record>
"logging.googleapis.com/labels" ${File.foreach("/k8s/labels").map{ |line| /^(.*)=\"(.*)\"$/.match(line)[1..2] }.map{ |k,v| [ "k8s-pod/#{k}", v] }.to_h }
</record>
</filter>
# Add a unique insertId to each log entry that doesn't already have it.
# This helps guarantee the order and prevent log duplication.
<filter **>
@type add_insert_ids
</filter>
# Configure all sources to output to Google Cloud Logging
<match **>
@type google_cloud
buffer_type file
buffer_path /var/log/google-fluentd/buffers
# Set the chunk limit conservatively to avoid exceeding the recommended
# chunk size of 5MB per write request.
buffer_chunk_limit 512KB
# Flush logs every 5 seconds, even if the buffer is not full.
flush_interval 5s
# Enforce some limit on the number of retries.
disable_retry_limit false
# After 3 retries, a given chunk will be discarded.
retry_limit 3
# Wait 10 seconds before the first retry. The wait interval will be doubled on
# each following retry (20s, 40s...) until it hits the retry limit.
retry_wait 10
# Never wait longer than 5 minutes between retries. If the wait interval
# reaches this limit, the exponentiation stops.
# Given the default config, this limit should never be reached, but if
# retry_limit and retry_wait are customized, this limit might take effect.
max_retry_wait 300
# Use multiple threads for processing.
num_threads 8
detect_json true
# Use the gRPC transport.
use_grpc true
</match>