【问题标题】:awslogs all logs are being skippedawslogs 所有日志都被跳过
【发布时间】:2020-07-06 15:04:34
【问题描述】:

我已经设置了 awslogs,它会将日志发送到 cloudwatch。它可以正常工作几个小时,然后突然停止。

这是来自 awslogs.log 的日志

2020-07-06 14:58:27,701 - cwlogs.push.reader - WARNING - 23093 - Thread-6 - Fall back to previous event time: {'timestamp': 1594062573000, 'start_position': 85848600L, 'end_position': 85848777L}, previousEventTime: 1594062573000, reason: timestamp could not be parsed from message.
2020-07-06 14:58:27,701 - cwlogs.push.batch - WARNING - 23093 - Thread-6 - Skip event: {'timestamp': 1594062573000, 'start_position': 85848600L, 'end_position': 85848777L}, reason: timestamp is more than 2 hours in future.
2020-07-06 14:58:27,701 - cwlogs.push.reader - WARNING - 23093 - Thread-6 - Fall back to previous event time: {'timestamp': 1594062573000, 'start_position': 85848777L, 'end_position': 85848952L}, previousEventTime: 1594062573000, reason: timestamp could not be parsed from message.
2020-07-06 14:58:27,701 - cwlogs.push.batch - WARNING - 23093 - Thread-6 - Skip event: {'timestamp': 1594062573000, 'start_position': 85848777L, 'end_position': 85848952L}, reason: timestamp is more than 2 hours in future.

这是我在 /var/awslogs/etc/config/api.conf 中的配置

[/var/log/app.js/api.log]
datetime_format = %Y-%m-%d %H:%M:%S
buffer_duration = 5000
log_stream_name = {hostname}
initial_position = end_of_file
log_group_name = app-js-logs-prod
file = /var/log/app.js/api.log

[/root/.pm2/pm2.log]
datetime_format = %Y-%m-%d %H:%M:%S
buffer_duration = 5000
log_stream_name = {hostname}
initial_position = end_of_file
log_group_name = pm2-logs-prod

我无法找出跳过日志的原因。任何帮助将不胜感激。

编辑:

timedatectl 输出:

root@ip-10-0-5-68:/home/ubuntu# timedatectl
                      Local time: Mon 2020-07-06 15:18:42 UTC
                  Universal time: Mon 2020-07-06 15:18:42 UTC
                        RTC time: Mon 2020-07-06 15:18:43
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: yes
systemd-timesyncd.service active: yes

我的当地时间应该是 IST。我的系统有问题吗?

【问题讨论】:

    标签: amazon-web-services amazon-cloudwatch


    【解决方案1】:

    在将请求发送到 CloudWatch 之前,系统会根据代理认为的时间对您的日志文件中的已解析日志执行检查。

    您应首先验证系统时间是否正确(在其当前时区中)并确保日志日期时区与本地时区匹配(这是默认时区)。

    如果这些匹配,则重启 cloudwatch 代理。

    如果仍然无法解决,请遵循previous post 上的一些建议

    【讨论】:

    • 我看到了之前的帖子链接。这解决了问题,但我不能一次又一次地手动执行此操作。那是我的问题。有没有我可以使用的解决方法。也许稍微修改一下我的配置文件。我已经准备好做一些权衡了。
    • 我认为这很可能是系统问题,不幸的是 cwlogs 现在实际上是一个遗留产品,因此支持可能很少。 CloudWatch 代理是它的替代品:docs.aws.amazon.com/systems-manager/latest/userguide/…
    • 我已经用 timedatectl 输出编辑了我的问题。我的本地时区是 IST,但它显示的是 UTC。
    • 我没有更新我的时区。默认情况下,它以 UTC 显示。
    • 这是默认设置,通常最好的做法是在 UTC 中运行您的服务器。但是,如果您想更新到 IST,则需要运行 timedatectl set-timezone Asia/Kolkata
    猜你喜欢
    • 2016-07-26
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-05
    相关资源
    最近更新 更多