Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add custom log files to the logs captured by elastic beanstalk's 'eb logs' command?

When I request the log files for an elastic beanstalk environment either through the web interface or "eb logs" I get the contents of the log files /var/log/eb-version-deployment.log, /opt/python/log/httpd.out, /var/log/cfn-hup.log, and several others.

Is there a way to add an additional log such as test_output.log to logs collected by the web interface and "eb logs"?

like image 546
user12345678 Avatar asked Sep 10 '14 00:09

user12345678


People also ask

Where does AWS Beanstalk store the application files and server log files?

Logs created by the web server, application server, Elastic Beanstalk platform scripts, and AWS CloudFormation are stored locally on individual instances. You can easily retrieve them by using the environment management console or the EB CLI.

Where are Elastic Beanstalk logs stored?

Elastic Beanstalk creates a bucket named elasticbeanstalk- region - account-id for each AWS Region in which you create environments. Within this bucket, logs are stored under the path resources/environments/logs/ logtype / environment-id / instance-id .

Where are logs stored in AWS?

To see your log data, sign in to the AWS Management Console, and open the CloudWatch console. In the left navigation pane, choose the Logs tab. Find your log group in the list of groups and open the log group. Your log group name is the Name that you set when you set up logging in the Amazon OpenSearch Service wizard.


1 Answers

Elastic Beanstalk looks in this folder for configuration files regarding which logs to tail:

/opt/elasticbeanstalk/tasks/taillogs.d/

On my box there are a handful of files there

[ec2-user@ip taillogs.d]$ ls -al
total 32
drwxr-xr-x 2 root root 4096 Sep 27 05:49 .
drwxr-xr-x 6 root root 4096 Sep 27 05:49 ..
-rw-r--r-- 1 root root   58 Sep 27 05:49 eb-activity.conf
-rw-r--r-- 1 root root   35 Sep 27 05:49 eb-version-deployment.conf
-rw-r--r-- 1 root root   16 Oct 15 03:44 httpd.conf
-rw-r--r-- 1 root root   16 Oct 15 03:44 nginx.conf
-rw-r--r-- 1 root root   26 Oct 15 03:44 nodejs.conf
-rw-r--r-- 1 root root   29 Oct 15 03:44 npm.conf

And each one has one line in it, like this:

/var/log/nodejs/nodejs.log

or

/var/log/nginx/*

Use .ebextensions to add a config file to tail your own logs:

files:
  "/opt/elasticbeanstalk/tasks/taillogs.d/my-app-logs.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/log/my-app.log

More info here:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-extend

like image 131
Samuel Neff Avatar answered Sep 19 '22 07:09

Samuel Neff