Open max-blue opened 1 year ago
The goal of this is to match all log messages right?
$log ^.*$
Try this instead:
$log ^[\S]+$
I found this while working on this project, that was the regex that worked in FLB to match all logs- IIRC I tried the same regex you have and it didn't work, I am not sure why: https://github.com/aws/aws-for-fluent-bit/pull/499/files#diff-1413562a024b7a0a612040a520fe770ac13e9d3fcc799d78bd48a808a6230905R23
I'll add a debugging guide entry for this.
I'll also update this tutorial as well: https://github.com/aws/aws-for-fluent-bit/tree/dev/use_cases/k8s-metadata-customize-tag
I am still not able to send logs to the correct path in s3. I have tried updated the config several different ways. Below is my latest config.
apiVersion: v1
data:
custom_parsers.conf: |
[PARSER]
Name docker_no_time
Format json
Time_Keep Off
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L
fluent-bit.conf: |
[SERVICE]
Daemon Off
Flush 1
Log_Level debug
Parsers_File parsers.conf
Parsers_File custom_parsers.conf
HTTP_Server On
HTTP_Listen 0.0.0.0
HTTP_Port 2022
Health_Check On
[INPUT]
Name tail
Tag s3logs.*
Path /var/log/containers/*.log
parser cri
multiline.parser cri
Mem_Buf_Limit 5MB
Skip_Long_Lines On
Skip_Empty_Lines On
Refresh_Interval 10
[FILTER]
Name kubernetes
Match s3logs.*
Kube_Tag_Prefix s3logs.var.log.containers.
Merge_Log On
K8S-Logging.Parser On
K8S-Logging.Exclude On
Keep_Log Off
Labels Off
Annotations Off
[FILTER]
Name rewrite_tag
Match s3logs.*
Rule $kubernetes['namespace_name'] ^[a-zA-Z0-9-_]*$ $kubernetes['namespace_name'].$kubernetes['container_name'].$kubernetes['pod_id'] false
[FILTER]
Name record_modifier
Match s3logs.*
Record cluster_name ${CLUSTER}
[OUTPUT]
Name s3
Match s3logs.*
bucket logs.company.us-east-1.domain.com
region us-east-1
s3_key_format /%Y/%m/%d/$TAG[1]/$TAG[2]/$TAG[2]-$TAG[1]-%Y%m%d-$TAG[3].txt
store_dir /var/log/fluentbit-s3-buffers
total_file_size 256MB
upload_timeout 2m
use_put_object On
compression gzip
preserve_data_ordering On
Did you try my suggestion here? => https://github.com/aws/aws-for-fluent-bit/issues/748#issuecomment-1769725235
Also, your input sets this tag:
[INPUT]
Name tail Tag s3logs.*
But then the rewrite_tag rule will change the tag to start with $kubernetes['namespace_name']
But then your S3 match pattern is:
Match s3logs.*
So your S3 output only matches logs which did not have their tag rewritten by the rewrite_tag filter I think .
Describe the question/issue
I converted FluentD with Fluent-bit to ship logs from K8S to S3. The tag_rewrite config I have is not working as expected and pushing logs to the incorrect path in S3. Logs are expected to push in the following path:
2023/10/14/namespace/container_name/container-name-namespace_name-2023-10-14-UUID.txt
but it gets pushed in to the following path:
2023/10/14/var/log/containers/containers-var-20231014-0759-.log-object00N1PX3n
Configuration
Fluent Bit Log Output
Fluent Bit Version Info
Which AWS for Fluent Bit Versions have you tried? latest stable
Which versions have you seen the issue in? Are there any versions where you do not see the issue? All versions
Cluster Details
Application Details
Unknown
Steps to reproduce issue
Use the configuration above and the logs go in the wrong path.