amazon-s3 - Fluentd:将多个容器日志存储在一个文件中(AWS S3)
问题描述
我想将多个容器日志存储在 AWS S3 的单个文件中。
我们有一个应用程序的多个组件,比如说ui、server、engine、alert。所有在 AWS EKS 集群中作为 pod 运行。
我有一个FluentD 守护程序集,用于将 S3 中的所有日志存储在单独的文件中(s3://app/app-ui-1.log、s3://app/app-server-1.log、s3://app/app -engine-1.log, s3://app/app-alert-1.log),工作正常。
但我的要求是将所有组件日志存储在一个文件中-> s3://app/app-all-logs/1.log
内容应该喜欢
<TIMESTAMP> UI-Log message
<TIMESTAMP> UI-Log message
<TIMESTAMP> SERVER-Log message
<TIMESTAMP> ENGINE-Log message
我尝试使用以下 FluentD 配置,但它将每个组件的日志存储在单独的文件中,例如
UI日志转到 s3://app/app-all-logs/ 1.log
服务器日志转到 s3://app/app-all-logs/ 2.log
引擎日志转到 s3://app/app-all-logs/ 3.log
FluentD 配置文件:
<source>
@type tail
path /var/log/containers/app-*.log
pos_file /var/log/all/all.log.pos
tag all.**
<parse>
@type none
</parse>
read_from_head true
</source>
<match all.**>
@type s3
aws_key_id "#{ENV['AWS_ACCESS_KEY']}"
aws_sec_key "#{ENV['AWS_SECRET_ACCESS_KEY']}"
s3_bucket "#{ENV['S3_LOGS_BUCKET_NAME']}"
s3_region "#{ENV['S3_LOGS_BUCKET_REGION']}"
path "#{ENV['S3_LOGS_BUCKET_PREFIX']}"
s3_object_key_format %{path}/app-all-logs/%Y%m%d/%{index}.log
buffer_chunk_limit 20m
buffer_path /var/log/all/fluentd-buffer
store_as log
flush_interval 600s
time_slice_format %Y/%m/%d
utc
<format>
@type single_value
</format>
<instance_profile_credentials>
ip_address IP_ADDRESS
port PORT
</instance_profile_credentials>
</match>
解决方案
推荐阅读
- java - 如何在 java 8 的一条语句中返回以下代码?
- java - 如何使用 Webflux 异步将对象放入 S3?
- c# - 使用 C# Mongo 驱动程序通过 $regex 搜索构建 Mongo 聚合管道查询
- python - Disxord.py 上的非前缀消息
- wso2 - 无法将 WSO2 身份服务器用于 OIDC。获取无法处理请求 /oauth2/authorize 异常
- python - 将 np.nan 转换为 pd.NA
- android - 以编程方式连接到特定的 wifi
- asp.net - 为什么我的 ASP.net mvc 应用程序不再在 IIS 下运行?
- java - 如果我使用 GlyphLayout 绘制位图字体,LibGDX 文本会失真
- windows-10 - DigitalPersona U.are.U 4500 指纹读取器 SDK 不适用于 Windows 10