

Ignore noisy logs with fluentd in EKS or other Kubernetes clusters
source link: https://www.jeffgeerling.com/blog/2021/ignore-noisy-logs-fluentd-eks-or-other-kubernetes-clusters
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Ignore noisy logs with fluentd in EKS or other Kubernetes clusters
March 16, 2021
Recently, I decided to use the fluentd-kubernetes-daemonset project to easily ship all logs from an EKS Kubernetes cluster in Amazon to an Elasticsearch cluster operating elsewhere.
The initial configuration worked great out of the box—just fill in details like the FLUENT_ELASTICSEARCH_HOST
and any authentication info, and then deploy the RBAC rules and DaemonSet into your cluster, and you're off to the races (assuming your Elasticsearch instance is configured to allow access from the cluster!).
But once I did that, I noticed the brand new EKS cluster was sending over 16,000 log messages per second to Elasticsearch. Doing a tiny bit of analysis (not much was required, honestly), I found that over 98% of the logs were coming from two EKS-specific noisy containers, efs-csi-node
and ebs-snapshot-controller
.
Reading through the docs for the fluentd daemonset, I found the environment variable FLUENT_CONTAINER_TAIL_EXCLUDE_PATH
, which can be used to specify Fluentd's exclude_path
configuration. Using that variable, you can tell Fluentd to ignore any paths matching an array of strings.
So in my case, I added the following configuration to the DaemonSet, and all the noise died down (and my poor Elasticsearch cluster breathed a sigh of relief—this was the first of six K8s clusters I was about to start shipping longs from!):
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
...
spec:
...
template:
spec:
serviceAccount: fluentd
serviceAccountName: fluentd
containers:
- name: fluentd
image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
env:
- name: FLUENT_ELASTICSEARCH_HOST
value: "192.168.0.10"
- name: FLUENT_ELASTICSEARCH_PORT
value: "9200"
- name: FLUENT_ELASTICSEARCH_SCHEME
value: "http"
- name: FLUENT_ELASTICSEARCH_LOGSTASH_PREFIX
value: "my-cluster"
- name: FLUENT_CONTAINER_TAIL_EXCLUDE_PATH
value: >
[
"/var/log/containers/efs-csi-node-*",
"/var/log/containers/ebs-snapshot-controller-*"
]
Once a fluentd Pod starts up on one of the nodes, if you inspect the logs, you'll notice the config file then gets an entry like:
exclude_path [ "/var/log/containers/efs-csi-node-*", "/var/log/containers/ebs-snapshot-controller-*" ]
And you don't have to pay for many gigabytes of extra log storage!
Recommend
-
92
Professionals | Community Groups Programs | Google Developers
-
110
来自用户的最佳实践分享,如何用阿里开源的Docker日志收集工具fluentd-pilot收集机器上所有Docker应用日志。fluentd-pilot简介fluentd-pilot是阿里开源的docker日志收集工具,
-
82
Home Blog
-
63
一、logstash Logstash: 是一个灵活的数据传输和处理系统,在beats出来之前,还负责进行数据收集。Logstash的任务,就是将各种各样的数据,经过配置转化规则,统一化存入Elasticsearch。使用Ruby开发的Logstash在灵活性上,非...
-
43
-
103
更新至 Fluentd 1.0 版本 更新至 Spring Boot 2.2.2.RELEASE 版本 Logback Spring Boot 默认使用 Logback 记录日志。 Logback 日志文件配置: ...
-
9
Simple logging with Elastic Cloud Kubernetes and Fluentd
-
37
Java and Spring Boot multiline log support for Fluentd (EFK stack) October 12, 2020October 12, 2020 / by Author Arnold Galovics For a well-functioning application deve...
-
14
fluentd的配置 <source> type tail path "/var/log/*.log" pos_file "/var/log/*.log.pos" tag "test" refresh_interval 120 format multiline format_firstline /\d{4}-\d{1,2}-\d{1,2}/ format1 /^(?...
-
4
fluentd2 是一个针对日志的收集、处理、转发系统。通过丰富的插件系统, 可以收集来自于各种系统或应用的日志...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK