我在Kubernetes中使用fluent-bit将日志转发到Splunk。我们将对多个Kubernetes集群使用相同的Splunk索引,因此我希望将从fluent-bit转发的每个事件标记为它所来自的集群。
我尝试使用modify功能在事件中“添加”或“设置”一个新字段。
fluent-bit-filter.conf: |-
[FILTER]
Name kubernetes
Match kube.*
Kube_Tag_Prefix kube.var.log.containers.
Kube_URL https://kubernetes.default.svc:443
Kube_CA_File /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
Kube_Token_File /var/run/secrets/kubernetes.io/serviceaccount/token
K8S-Logging.Parser On
K8S-Logging.Exclude On
Add cluster devcluster我实际收到的示例日志(缺少新添加的“cluster”字段)
[305] kube.var.log.containers.calico-node-xzwnv_kube-system_calico-node-a4a6a2261a76ec419e9cf13ae39732b3e918726573cf1a0dece648e679011578.log: [1565578883.799679612, {"log"=>"2019-08-12 03:01:23.799 [INFO][68] int_dataplane.go 830: Received interface update msg=&intdataplane.ifaceUpdate{Name:"cali5d1a7318787", State:"up"}发布于 2019-08-13 03:54:35
我想通了。您必须使用名为modify的单独筛选器。在使用helm图表时,您需要在values.yaml中添加一个名为rawConfig的部分,并将额外的过滤器放在@INCLUDE for fluent-bit-filter.conf之间
rawConfig: |-
@INCLUDE fluent-bit-service.conf
@INCLUDE fluent-bit-input.conf
@INCLUDE fluent-bit-filter.conf
[FILTER]
Name modify
Match *
Add cluster devcluster
@INCLUDE fluent-bit-output.conf发布于 2019-09-03 23:44:49
对于那些使用configmap.yaml的人,请添加此部分:
filter.conf: |
[FILTER]
Name modify
Match *
Add KEY VALUEhttps://stackoverflow.com/questions/57467070
复制相似问题