1

我在服务器上运行awslogs 代理,当我在 AWS 控制台中查看 CloudWatch 日志时,日志大约晚了 60 分钟。我们的服务器每小时产生大约 650MB 的数据,代理似乎跟不上。

这是我们的缩写配置文件:

[application.log]
datetime_format = %Y-%m-%d %H:%M:%S
time_zone = UTC
file = var/output/logs/application.json.log*
log_stream_name = {hostname}
initial_position = start_of_file
log_group_name = ApplicationLog

[service_log]
datetime_format = %Y-%m-%dT%H:%M:%S
time_zone = UTC
file = var/output/logs/service.json.log*
log_stream_name = {hostname}
initial_position = start_of_file
log_group_name = ServiceLog

有没有一种通用的方法来加快 awslogs 代理的速度?

4

2 回答 2

5

数据量 (> 0.2MB/s) 对代理来说不是问题。该代理的每个日志文件的容量约为 3MB/s。但是,如果您对多个日志文件使用相同的日志流,代理会写入相同的流,最终会相互阻塞。当您在日志文件之间共享流时,吞吐量会减半。

此外,还有一些可以配置的属性可能会影响性能:

buffer_duration = <integer>
batch_count = <integer>
batch_size = <integer>

为了解决我的问题,我做了两件事:

  1. 大幅增加批量大小(默认为 32768 字节)
  2. 为每个日志文件使用不同的日志流

并且代理没有问题跟上。这是我的最终配置文件:

[application.log]
datetime_format = %Y-%m-%d %H:%M:%S
time_zone = UTC
file = var/output/logs/application.json.log*
log_stream_name = {hostname}-app
initial_position = start_of_file
log_group_name = ApplicationLog
batch_size = 524288

[service_log]
datetime_format = %Y-%m-%dT%H:%M:%S
time_zone = UTC
file = var/output/logs/service.json.log*
log_stream_name = {hostname}-service
initial_position = start_of_file
log_group_name = ServiceLog
batch_size = 524288
于 2016-06-14T05:07:25.263 回答
0

awslogs 代理支持日志轮换,因此:

file = var/output/logs/application.json.log*

会拿起太多的文件?

尝试:

file = var/output/logs/application.json.log

以加快进程。

于 2017-10-23T15:36:21.737 回答