Skip to content

Commit 39dc725

Browse files
authored
fix: Changed fluentd config to prevent excess logging from the daemonset pods (#174)
* fix: Changed fluentd config to prevent excess logging from the daemonset pods * Fix formatting in systemd conf
1 parent 97882e1 commit 39dc725

3 files changed

Lines changed: 33 additions & 17 deletions

File tree

templates/kubernetes/terraform/modules/kubernetes/logging/cloudwatch/files/host.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@
6666
retry_forever true
6767
</buffer>
6868
</match>
69-
</label>
69+
</label>

templates/kubernetes/terraform/modules/kubernetes/logging/cloudwatch/files/systemd.conf

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
@type systemd
33
@id in_systemd_kubelet
44
@label @systemd
5-
filters [{ "_SYSTEMD_UNIT": "kubelet.service" }]
5+
matches [{ "_SYSTEMD_UNIT": "kubelet.service" }]
66
<entry>
7-
field_map {"MESSAGE": "message", "_HOSTNAME": "hostname", "_SYSTEMD_UNIT": "systemd_unit"}
8-
field_map_strict true
7+
field_map {"MESSAGE": "message", "_HOSTNAME": "hostname", "_SYSTEMD_UNIT": "systemd_unit"}
8+
field_map_strict true
99
</entry>
10+
<storage>
11+
@type local
12+
persistent true
13+
path /var/log/fluentd-journald-kubelet.pos
14+
</storage>
1015
path /var/log/journal
11-
pos_file /var/log/fluentd-journald-kubelet.pos
1216
read_from_head true
1317
tag kubelet.service
1418
</source>
@@ -17,13 +21,17 @@
1721
@type systemd
1822
@id in_systemd_kubeproxy
1923
@label @systemd
20-
filters [{ "_SYSTEMD_UNIT": "kubeproxy.service" }]
24+
matches [{ "_SYSTEMD_UNIT": "kubeproxy.service" }]
2125
<entry>
22-
field_map {"MESSAGE": "message", "_HOSTNAME": "hostname", "_SYSTEMD_UNIT": "systemd_unit"}
23-
field_map_strict true
26+
field_map {"MESSAGE": "message", "_HOSTNAME": "hostname", "_SYSTEMD_UNIT": "systemd_unit"}
27+
field_map_strict true
2428
</entry>
29+
<storage>
30+
@type local
31+
persistent true
32+
path /var/log/fluentd-journald-kubeproxy.pos
33+
</storage>
2534
path /var/log/journal
26-
pos_file /var/log/fluentd-journald-kubeproxy.pos
2735
read_from_head true
2836
tag kubeproxy.service
2937
</source>
@@ -32,13 +40,17 @@
3240
@type systemd
3341
@id in_systemd_docker
3442
@label @systemd
35-
filters [{ "_SYSTEMD_UNIT": "docker.service" }]
43+
matches [{ "_SYSTEMD_UNIT": "docker.service" }]
3644
<entry>
37-
field_map {"MESSAGE": "message", "_HOSTNAME": "hostname", "_SYSTEMD_UNIT": "systemd_unit"}
38-
field_map_strict true
45+
field_map {"MESSAGE": "message", "_HOSTNAME": "hostname", "_SYSTEMD_UNIT": "systemd_unit"}
46+
field_map_strict true
3947
</entry>
48+
<storage>
49+
@type local
50+
persistent true
51+
path /var/log/fluentd-journald-docker.pos
52+
</storage>
4053
path /var/log/journal
41-
pos_file /var/log/fluentd-journald-docker.pos
4254
read_from_head true
4355
tag docker.service
4456
</source>
@@ -72,4 +84,4 @@
7284
retry_forever true
7385
</buffer>
7486
</match>
75-
</label>
87+
</label>

templates/kubernetes/terraform/modules/kubernetes/logging/cloudwatch/fluentd.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ resource "kubernetes_config_map" "cluster_info" {
2828

2929
resource "kubernetes_service_account" "fluentd" {
3030
metadata {
31-
name = "fluentd"
32-
namespace = "amazon-cloudwatch"
31+
name = "fluentd"
32+
namespace = "amazon-cloudwatch"
3333
annotations = {
3434
"eks.amazonaws.com/role-arn" = module.iam_assumable_role_fluentd.this_iam_role_arn
3535
}
@@ -178,6 +178,10 @@ resource "kubernetes_daemonset" "fluentd_cloudwatch" {
178178
}
179179
}
180180
}
181+
env {
182+
name = "FLUENTD_OPT"
183+
value = "-q"
184+
}
181185
resources {
182186
limits {
183187
memory = "200Mi"
@@ -217,7 +221,7 @@ resource "kubernetes_daemonset" "fluentd_cloudwatch" {
217221
}
218222

219223
security_context {
220-
fs_group = 65534
224+
fs_group = 65534
221225
}
222226

223227
termination_grace_period_seconds = 30

0 commit comments

Comments
 (0)