【问题标题】:logs from only some files showing up aws cloudwatch仅来自显示 aws cloudwatch 的一些文件的日志
【发布时间】:2016-08-25 17:27:11
【问题描述】:

我在我的 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

【问题讨论】:

  • 检查 /var/log/awslogs.log 以了解 CloudWatch Logs 代理记录的任何错误。
  • 嗨,马克,感谢您的回复。我更新了我的帖子以包含我的 awslogs.log。你能看一下吗?
  • 马克,我注意到我的日志使用的是 awslogs.conf,而不是我在其中写入文件的 awscli.conf。awsconf 文件已经具有从消息文件获取日志的设置

标签: amazon-web-services


【解决方案1】:

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

  • 选项 1: 为您的配置块标题使用新名称。
    • 即把[/var/log/cron]改成[/something/else]
  • 方案二:停止服务后删除代理状态文件。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-01
    • 1970-01-01
    • 2022-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    相关资源
    最近更新 更多