如何获取log fluentd的特定名称空间
因此,我想从特定的名称空间获取日志并将其发送到OpenSearch,因此我没有线索,所以我决定尝试这样做:
apiVersion: v1
kind: ConfigMap
metadata:
labels:
k8s-app: fluentd-logging
name: simple-fluentd-configmap
namespace: fluent-log
data:
fluent.conf: |
<match fluent.**>
@type null
</match>
<source>
@type tail
path /var/log/pods/containers*.log
pos_file /var/log/containers.pos
format none
<filter **>
@type record_modifier
remove_keys "container_id,source"
@type parser
key_name log
hash_value_field log
<parse>
@type json
</parse>
</filter>
<match kubernetes.var.log.containers.**access**.log>
@type opensearch
port 443
logstash_format false
scheme https
ssl_verify false
</match>
<match kubernetes.var.log.containers.**balance**.log>
@type opensearch
port 443
logstash_format false
scheme https
ssl_verify false
</match>
因此,问题是如何使其根据来自从中的名称空间发送特定的日志kubernetes?
So I wanted to fetch logs from a specific namespace and send them to opensearch, so I didn't get a clue so I decided to try to make it like this:
apiVersion: v1
kind: ConfigMap
metadata:
labels:
k8s-app: fluentd-logging
name: simple-fluentd-configmap
namespace: fluent-log
data:
fluent.conf: |
<match fluent.**>
@type null
</match>
<source>
@type tail
path /var/log/pods/containers*.log
pos_file /var/log/containers.pos
format none
<filter **>
@type record_modifier
remove_keys "container_id,source"
@type parser
key_name log
hash_value_field log
<parse>
@type json
</parse>
</filter>
<match kubernetes.var.log.containers.**access**.log>
@type opensearch
port 443
logstash_format false
scheme https
ssl_verify false
</match>
<match kubernetes.var.log.containers.**balance**.log>
@type opensearch
port 443
logstash_format false
scheme https
ssl_verify false
</match>
So the question is how to make it send specific logs based on namespace from kubernetes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
配置中的第二个匹配子句(从
kubernetes.var.log ...
开始的一个开始,应包含名称空间,因此您可以根据特定的名称空间过滤并决定如何处理这些特定日志。如果出于任何原因,群集中的日志路径不包含其路径中的命名空间,则还可以使用 kubernetes 插件。
它将用与群集相关的元数据丰富您的日志,并允许您提取源自源自的名称空间日志并相应地处理它们。
The second match clause in your configuration (the one starting with
kubernetes.var.log...
) should contain the namespace, and therefore you can filter based on specific namespaces and decide how to handle those specific logs.If, for any reason, the log path in your cluster does not contain the namespace in its path, you can also use the kubernetes plugin.
It will enrich your logs with metadata relevant to the cluster, and allow you to extract the namespace logs originated from and deal with them accordingly.