5

Currently using the Amazon web services, I successfully deployed multiple applications on Elastic Beanstalk ( with green cluster health) as Docker containers.

The problem however arises when I try to get the logs with the console; when I do "request logs", no log is found. When I then return in on the dashboard after having requested the logs, a new event/error has appeared:

[Instance: i-123456789] Command failed on instance. Return code: 1 Output: bundleLogs.py --conf-path '/opt/elasticbeanstalk/tasks/bundlelogs.d/*' --location-prefix 'resources/environments/logs/bundle/' Unable to execute method publish_contents_from_filename on any of the target objects. For more detail, check /var/log/eb-activity.log using console or EB CLI.

Trying to solve the problem, I SSHed into my cluster and used the following command to find the logs into my Docker container:

sudo docker exec myinstance cat /var/log/logstash_activity.log

My logs are found as expected.

Trying to learn more about the error, I gave a peek into the /var/log/eb-activity.log and found the following lines:

[2015-07-06T12:54:30.137Z] INFO  [26993] - [CMD-BundleLogs] : Starting activity...
[2015-07-06T12:54:30.363Z] INFO  [26993] - [CMD-BundleLogs/AddonsBefore] : Starting activity...
[2015-07-06T12:54:30.363Z] INFO  [26993] - [CMD-BundleLogs/AddonsBefore] : Completed activity.
[2015-07-06T12:54:30.363Z] INFO  [26993] - [CMD-BundleLogs/BundleLogs] : Starting activity...
[2015-07-06T12:54:30.364Z] INFO  [26993] - [CMD-BundleLogs/BundleLogs/BundleLogs] : Starting activity...
[2015-07-06T12:54:30.627Z] INFO  [26993] - [CMD-BundleLogs/BundleLogs/BundleLogs] : Activity execution failed, because: bundleLogs.py --conf-path '/opt/elasticbeanstalk/tasks/bundlelogs.d/*' --location-prefix 'resources/environments/logs/bundle/'
Unable to execute method publish_contents_from_filename on any of the target objects (Executor::NonZeroExitStatus)


[2015-07-06T12:54:30.627Z] INFO  [26993] - [CMD-BundleLogs/BundleLogs/BundleLogs] : Activity failed.
[2015-07-06T12:54:30.627Z] INFO  [26993] - [CMD-BundleLogs/BundleLogs] : Activity failed.
[2015-07-06T12:54:30.627Z] INFO  [26993] - [CMD-BundleLogs] : Completed activity. Result:
Command CMD-BundleLogs failed.

The error message didn't help me much however.

In the "Logging" field of my Dockerrun.aws.json, I gave the path "/var/log" since it is the folder that contains my app logs, among others. I also tried the value "/var/log/logstash_activity.log" without more success.

Why can't the Beanstalk console find my apps' logs?

Heschoon
  • 241
  • 1
  • 9

2 Answers2

1

Old question, but I just figured this for our apps. What user policy are you using? If you are using ReadOnly, The default policy “AWSElasticBeanstalkReadOnlyAccess” does not include log download capability. In the aws documentation, theres an example of an IAM policy that can be created for a user to enable this functionality.

See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.managed-policies.html under “Creating a Custom User Policy”. The final example shows the needed S3 permissions that need to be granted on top of what is already provided in the ReadOnlyAccess policy in order to bundle and download the logs.

user988544
  • 111
  • 1
0

Sadly the existing answer did not help me much. It was something related to S3 rights still.

I had to adjust the instance rights to the following and it worked

{
    "Sid": "AllowS3ForEBLogs",
    "Action": [
        "s3:Get*",
        "s3:List*",
        "s3:PutObject"
    ],
    "Effect": "Allow",
    "Resource": [
        "arn:aws:s3:::elasticbeanstalk-*",
        "arn:aws:s3:::elasticbeanstalk-*/resources/environments/logs/*"
    ]

}

My inspiration was this.

lony
  • 101
  • 4