只显示一些显示aws cloudwatch的文件

时间:2016-08-25 17:27:11

标签: amazon-web-services

我在我的linux实例上配置了aws cloudwatch日志服务。在配置文件中,我将其设置为跟踪3个日志文件:

[general]
state_file = /var/lib/awslogs/agent-state

[plugins]
cwlogs = cwlogs
[default]
region = us-west-1

[/var/log/cron]
file = /var/log/cron
log_group_name = /var/log/cron
log_stream_name = {instance_id}
datetime_format = %b %d %H:%M:%S

[/var/log/messages]
file = /var/log/messages
log_group_name = /var/log/messages
log_stream_name = {instance_id}
datetime_format = %b %d %H:%M:%S

[/var/log/test.log]
file = /var/log/test.log
log_group_name = /var/log/test.log
log_stream_name = {instance_id}
datetime_format = %b %d %H:%M:%S

然而,在我的控制台中,我只看到从消息中显示的日志。我试图跟踪的3个文件的权限是-rw-------

有人知道为什么会这样吗?我将测试日志回显到每个单独的文件中,只显示插入到消息中的文件。

编辑**:这是我的awslogs.log

2016-08-25 17:58:31,227 - cwlogs.push - INFO - 631 - MainThread - Missing or invalid value for use_gzip_http_content_encoding config. Defaulting to using gzip encoding.
2016-08-25 17:58:31,228 - cwlogs.push - INFO - 631 - MainThread - Using default logging configuration.
2016-08-25 17:58:31,234 - cwlogs.push.stream - INFO - 631 - Thread-1 - Starting publisher for [d4a8beb9b6b4535cac41dc75f252df59, /var/log/messages]
2016-08-25 17:58:31,234 - cwlogs.push.stream - INFO - 631 - Thread-1 - Starting reader for [d4a8beb9b6b4535cac41dc75f252df59, /var/log/messages]
2016-08-25 17:58:31,235 - cwlogs.push.reader - INFO - 631 - Thread-4 - Replay events end at 52578.
2016-08-25 17:58:31,235 - cwlogs.push.reader - INFO - 631 - Thread-4 - Start reading file from 52284.
2016-08-25 17:58:32,308 - cwlogs.push.publisher - WARNING - 631 - Thread-2 - Caught exception: An error occurred (DataAlreadyAcceptedException) when calling the PutLogEvents operation: The given batch of log events has already been accepted. The next batch can be sent with sequenceToken: 49561203985967314162297491311273568778757530964511949634

1 个答案:

答案 0 :(得分:0)

您的代理状态文件可能已损坏,因为您不断更改配置。有两种方法可以解决这个问题:

  • 选项1:为配置块标题使用新名称。
    • 即,将[/var/log/cron]更改为[/something/else]
  • 选项2:停止服务后删除代理状态文件。

    sudo service awslogs stop
    sudo rm /var/lib/awslogs/agent-state
    sudo service awslogs start
    

请注意,选项2最初可能会在创建新状态文件时将重复日志推送到CloudWatch。