Amazon web services Elastic Beanstalk CloudWatch日志流停止工作–;如何调试

Amazon web services Elastic Beanstalk CloudWatch日志流停止工作–;如何调试,amazon-web-services,amazon-ec2,amazon-elastic-beanstalk,amazon-cloudwatchlogs,Amazon Web Services,Amazon Ec2,Amazon Elastic Beanstalk,Amazon Cloudwatchlogs,我的Elastic Beanstalk环境正在停止将node.js事件流式传输到CloudWatch日志。在新实例上,流式处理可以正常工作几分钟。查看几分钟后,CloudWatch中不再显示更多日志 我在“配置”>“软件配置”>“CloudWatch日志”>“日志流”(true)下设置了AWS Elastic Beanstalk以将日志流式传输到CloudWatch。我停用了日志流,并作为测试重新激活了它。看看cloudwatch 最后一个eb活动日志大约有10分钟 错误日志不可用(两个实例都

我的Elastic Beanstalk环境正在停止将node.js事件流式传输到CloudWatch日志。在新实例上,流式处理可以正常工作几分钟。查看几分钟后,CloudWatch中不再显示更多日志

我在“配置”>“软件配置”>“CloudWatch日志”>“日志流”(true)下设置了AWS Elastic Beanstalk以将日志流式传输到CloudWatch。我停用了日志流,并作为测试重新激活了它。看看cloudwatch

  • 最后一个eb活动日志大约有10分钟
  • 错误日志不可用(两个实例都不可用)
  • nginx/access.log是一个有秒历史的视图
  • nodejs.log大约有一个小时了(重新启动实例后不久)
不过,每次运行状况检查都会在每个视图秒将日志条目写入nodejs.log

我在ec2实例上没有找到任何关于日志流的日志

  • 有人有类似的问题吗
  • 如何将Elastic Beanstalk stream nodejs日志转换为CloudWatch日志
  • ---编辑

    当(@andrew ferk)和我激活日志流时,它使用当前日志在CloudWatch中创建了所有日志组和流。在我们再次部署之后,我们注意到日志停止了。这是因为aws散列日志的第一行。如果之前看到过该散列,则会将该文件视为已被处理

    如果您使用的是
    npm start
    ,则第一行将是应用程序的名称和版本

    您可以在dockerfile中添加一个
    CMD date&&npm start
    ,以每次触发不同的第一行,或在静默模式下运行npm(只要您的第一个输出是唯一的)

    此外,根据他们的文档,在启用该功能之前,您应该向elastic beanstalk添加一些策略


    以下常见问题解答可能会有所帮助:

    要检查是否正在流式传输自定义日志文件,请执行以下操作:

  • eb-ssh
    进入实例并查看
    /var/log/awslogs.log
    。如果这甚至没有提到“从(您的awslogs配置文件)加载其他配置”,请确保正确安装配置文件,并在安装后重新启动awslogs服务(可能使用
    .ebextensions
    。请参阅“自定义日志文件流”中。有关如何重新启动awslogs服务,请参阅中的
    命令
    部分
  • CloudWatch日志代理是有状态的。如果日志文件的前几行为空或从未更改,则可能需要设置
    文件\u指纹\u行
    。请参阅

  • 检查
    /var/log/awslogs.log文件中是否存在错误,并确保awslogs服务正常运行running@b.b3rn4rd:找到它,但是此文件从未提及nodejs日志,也没有任何与之相关的问题。您所指的文档中提到了它。我猜您指的是?我试图检查配置,但找不到eb-logs.config或任何其他描述的配置n该页面位于ec2实例的任意位置。在/var/log/awslogs.log中没有错误。而awslogs.log的前两个日志循环(2小时)将nodejs.logs发布到cloudwatch日志中。第三个los文件不再包含任何nodejs日志。没有任何错误。
    
    [ec2-user@ip-###-##-##-## log]$ cat /var/log/awslogs.log 
    2017-03-07 11:01:05,928 - cwlogs.push.stream - INFO - 31861 - Thread-1 - Detected file rotation, notifying reader
    2017-03-07 11:01:05,928 - cwlogs.push.stream - INFO - 31861 - Thread-1 - Reader is still alive.
    2017-03-07 11:01:05,928 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/error.log*'.
    2017-03-07 11:01:05,928 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/access.log*'.
    2017-03-07 11:01:06,052 - cwlogs.push.reader - INFO - 31861 - Thread-8 - No data is left. Reader is leaving.
    2017-03-07 11:01:10,929 - cwlogs.push.stream - INFO - 31861 - Thread-1 - Removing dead reader [2177a5cce5ed29525de329bfdc292ff1, /var/log/nginx/access.log]
    2017-03-07 11:01:10,929 - cwlogs.push.stream - INFO - 31861 - Thread-1 - Starting reader for [92257964a10edeb586f084f4f2ba35de, /var/log/nginx/access.log]
    2017-03-07 11:01:10,930 - cwlogs.push.reader - INFO - 31861 - Thread-11 - Start reading file from 0.
    2017-03-07 11:01:10,930 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/error.log*'.
    2017-03-07 11:01:10,930 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/access.log*'.
    2017-03-07 11:01:15,931 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/error.log*'.
    2017-03-07 11:01:15,931 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/access.log*'.
    2017-03-07 11:01:16,788 - cwlogs.push.publisher - INFO - 31861 - Thread-7 - Log group: /aws/elasticbeanstalk/production/var/log/nginx/access.log, log stream: i-0bd24767864801e2c, queue size: 0, Publish batch: {'skipped_events_count': 0, 'first_event': {'timestamp': 1488884470930, 'start_position': 0L, 'end_position': 114L}, 'fallback_events_count': 0, 'last_event': {'timestamp': 1488884472931, 'start_position': 341L, 'end_position': 454L}, 'source_id': '92257964a10edeb586f084f4f2ba35de', 'num_of_events': 4, 'batch_size_in_bytes': 554}
    2017-03-07 11:01:20,932 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/error.log*'.
    2017-03-07 11:01:20,932 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/access.log*'.
    2017-03-07 11:01:25,933 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/error.log*'.
    2017-03-07 11:01:25,933 - cwlogs.push.stream - WARNING - 31861 - Thread-1 - No file is found with given path '/var/log/httpd/access.log*'.
    2017-03-07 11:01:27,881 - cwlogs.push.publisher - INFO - 31861 - Thread-7 - Log group: /aws/elasticbeanstalk/production/var/log/nginx/access.log, log stream: i-0bd24767864801e2c, queue size: 0, Publish batch: {'skipped_events_count': 0, 'first_event': {'timestamp': 1488884481933, 'start_position': 454L, 'end_position': 568L}, 'fallback_events_count': 0, 'last_event': {'timestamp': 1488884482934, 'start_position': 568L, 'end_position': 681L}, 'source_id': '92257964a10edeb586f084f4f2ba35de', 'num_of_events': 2, 'batch_size_in_bytes': 277}
    
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "logs:CreateLogGroup",
            "logs:CreateLogStream",
            "logs:GetLogEvents",
            "logs:PutLogEvents",
            "logs:DescribeLogGroups",
            "logs:DescribeLogStreams",
            "logs:PutRetentionPolicy"
          ],
          "Resource": [
            "*"
          ]
        }
      ]
    }