如何过滤命名空间上的 filebeat 日志
我有一个集群,我在其中运行 filebeat 作为恶魔服务,以下是相同的配置图。我只想从命名空间 abc
获取日志,但我仍然从所有命名空间获取日志,特别是我从占用 75% 空间的 filebeat 获取有关 filebeat 的日志。配置有问题吗?或者还有另一种更好的方法吗?或者其他方式停止从 filebeat 获取有关 filebeat 的日志?
kind: ConfigMap
metadata:
name: filebeat-config
namespace: kube-system
labels:
k8s-app: filebeat
data:
filebeat.yml: |-
filebeat.autodiscover:
providers:
- type: kubernetes
node: ${NODE_NAME}
hints.enabled: true
hints.default_config:
type: container
paths:
- /var/log/containers/*${data.kubernetes.container.id}.log
templates:
- condition:
equals:
kubernetes.namespace: abc
output.logstash:
hosts: ['${LOGSTAH_HOST:elasticsearch}:${LOGSTASH_PORT:5044}']
logging.level: "info"```
I have cluster where i am running filebeat as demon service and following is the configmap for the same. I want to get logs only from the namespace abc
but I am still getting logs from all the name spaces, specially I am getting logs about filebeat from filebeat which is taking 75% of the space. Is anything wrong with configuration ? Or there is another better way to do it ? Or other way to stop getting the logs from filebeat about filebeat ?
kind: ConfigMap
metadata:
name: filebeat-config
namespace: kube-system
labels:
k8s-app: filebeat
data:
filebeat.yml: |-
filebeat.autodiscover:
providers:
- type: kubernetes
node: ${NODE_NAME}
hints.enabled: true
hints.default_config:
type: container
paths:
- /var/log/containers/*${data.kubernetes.container.id}.log
templates:
- condition:
equals:
kubernetes.namespace: abc
output.logstash:
hosts: ['${LOGSTAH_HOST:elasticsearch}:${LOGSTASH_PORT:5044}']
logging.level: "info"```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您仍然有
hints.enabled: true
设置。IMO 你只需要这个:
或者另一种方法是使用 POD 上的注释来记录或不记录。
来自文档
。您还可以完全禁用默认设置,因此只会检索像
co.elastic.logs/enabled: true
这样注释的 Pod:It is because you have still
hints.enabled: true
setting.IMO you only need this:
Or the other way would be to work with annotations on you PODs which should be logged or not.
From the documentation
E.g. you can also disable default settings entirely, so only Pods annotated like
co.elastic.logs/enabled: true
will be retrieved: