简体   繁体   中英

Fluentbit Kubernetes - How to extract fields from existing logs

I have configured EFK stack with Fluent-bit on my Kubernetes cluster. I can see the logs in Kibana.

I also have deployed nginx pod, I can see the logs of this nginx pod also in Kibana. But all the log data are sent to a single field "log" as shown below.

在此处输入图片说明

How can I extract each field into a separate field. There is a solution for fluentd already in this question. Kibana - How to extract fields from existing Kubernetes logs

But how can I achieve the same with fluent-bit?

I have tried the below by adding one more FILTER section under the default FILTER section for Kubernetes, but it didn't work.

 [FILTER] Name parser Match kube.* Key_name log Parser nginx

From this ( https://github.com/fluent/fluent-bit/issues/723 ), I can see there is no grok support for fluent-bit.

In our official documentation for Kubernetes filter we have an example about how to make your Pod suggest a parser for your data based in an annotation:

https://docs.fluentbit.io/manual/filter/kubernetes

Look at this configmap:

https://github.com/fluent/fluent-bit-kubernetes-logging/blob/master/output/elasticsearch/fluent-bit-configmap.yaml

The nginx parser should be there:

[PARSER]
        Name   nginx
        Format regex
        Regex ^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$
        Time_Key time
        Time_Format %d/%b/%Y:%H:%M:%S %z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM