Open ph-l opened 2 years ago
Thank you for this report. I believe this is an issue in EKS Fargate, not Fluent Bit itself. I will check on this.
EKS Fargate team is aware of the issue. Unfortunately I can't currently give any more information publicly.
Hello. Are there any updates on this issue?
@elite-tech does the fix mentioned here work for you: https://github.com/aws/containers-roadmap/issues/1625#issuecomment-1231023420
Unfortunately no @PettitWesley. The issue I have is related to the Kubernetes filter ignoring parsers set with annotations as defined here.
If I set the annotation "fluentbit.io/parser: cri_ping", the "cri_ping" parser is not used, it is ignored.The parser defined in the filter definition "cri" is still used. Below is the filter definition.
[FILTER]
Name kubernetes
Match kube.*
Merge_Log On
Merge_Parser cri
K8S-Logging.Parser On
K8S-Logging.Exclude On
@elite-tech does this only happen on EKS Fargate or with Fluent Bit in general?
Can you share your full config map and parser definition along with the pod annotation configuration.
This happens with EKS fargate. I have not tried using Fluentbit directly.
Here is the config map:
kind: ConfigMap
apiVersion: v1
metadata:
name: aws-logging
namespace: aws-observability
data:
flb_log_cw: "true" #ships fluent-bit process logs to CloudWatch
output.conf: |
[OUTPUT]
Name kinesis_firehose
Match *
region us-east-1
delivery_stream test-I20q76WS
parsers.conf: |
[PARSER]
Name cri
Format Regex
Regex ^(?<time>[^ ]+) (stdout|stderr) (P|F) (?<log>.*)$
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L%z
[PARSER]
Name cri_ping
Format Regex
Regex ^(?<time>[^ ]+) (stdout|stderr) (P|F) (?<sourcefile>/.+): (?<log>.*)$
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L%z
filters.conf: |
[FILTER]
Name kubernetes
Match kube.*
Merge_Log On
Merge_Parser cri
K8S-Logging.Parser On
K8S-Logging.Exclude On
Below are the annotations on the Pod
apiVersion: v1
kind: Pod
metadata:
annotations:
CapacityProvisioned: 2vCPU 5GB
Logging: LoggingEnabled
checksum/config: 7ae2cfd76cd1410753d86645a7fff95455fr402fa43acf715603aadb1688c9de
fluentbit.io/exclude-log-config-updater: "true"
fluentbit.io/parser: cri_ping
kubectl.kubernetes.io/restartedAt: "2023-01-10T13:17:49-06:00"
kubernetes.io/psp: eks.privileged
@elite-tech thank you. If I get some free time I can try to repro this myself. However, in the meantime, can you try to repro this on a k8s cluster that's not fargate? (like a local cluster may be). I'm wondering if the issue is that your cri_ping
parser does not actually work on the logs. It looks very similar to the normal cri parser, which I think should already be applied to the logs before your annotation parser is applied. The cri
built-in multiline parser should be applied by the tail input, though I actually don't see it in the docs, I will check on this: https://docs.aws.amazon.com/eks/latest/userguide/fargate-logging.html
EDIT/Update: I have confirmed from EKS Fargate team that the real tail input has this:
multiline.parser docker, cri
We will get the docs updated. So this means that cri
parsing logic will already be applied to your logs before they reach the kubernetes filter.
Looking at the code, it looks like it either uses the annotation parser, or the merge_log parser, not both: https://github.com/fluent/fluent-bit/blob/master/plugins/filter_kubernetes/kubernetes.c#L130
I would check the regex in that parser against the actual log content using this site recommended by Fluent community: https://rubular.com/
Do the logs match that regex?
@ph-l @PettitWesley I think the issue is if the parser has an underscore _
in the name. When I try to set the annotation fluentbit.io/parser: java_multiline
I'll get [filter:kubernetes:kubernetes.0] annotation parser 'java_multiline' not found
Even though I do have a parser named java_multiline
in parsers.conf
. However, if I set the annotation to a parser without an underscore, it works. e.g. fluentbit.io/parser: json
Doesn't seem to be an issue if there's a dash -
in the name, but I get an error for any parser with _
in it when using the Kubernetes annotation.
@fitchtech Can you share your Fluent Bit config and your pod manifest? My original example wasn't using underscores. I tried it again today and it's still not working for me.
Describe the question/issue
Using the built-in AWS Fluent Bit with EKS on Fargate, the parser defined in Kubernetes annotations on pods do not process logs.
Configuration
Fluent Bit config
Pod
Fluent Bit Log Output
Fluent Bit Version Info
Based on Fluent Bit process logs, it's Fluent Bit 1.7.9. I can't tell which version of AWS for Fluent Bit is used in Fargate.
Cluster Details
EKS on Fargate
Application Details
Steps to reproduce issue
I get the following (redacted) log record with my configuration. It appears that the parser suggested by the pod isn't used. I expect to see
mystream
key defined in annotation parser instead ofstream
key defined in Merge_Parser.If I specify an undefined parser in the pod annotations, I'll get a warning message in Fluent Bit's logs
If Merge_Parser is not set, the log content isn't processed even with the annotation parser defined.