Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a CLI to tail logs from AWS Elastic Beanstalk

Is there a CLI utility for tailing logs from Elastic Beanstalk applications. Specifically a python flask application.

You can use their eb CLI to get a snap shot ...

eb logs 

But I would like to do (similar to what heroku offers)...

eb logs --tail 

Has any one accomplished this?

Thanks!


Some references:

  • Working with logs on Elastic Beanstalk
  • EB CLI
like image 235
Jonathan Avatar asked Jun 11 '13 19:06

Jonathan


People also ask

How do I check AWS Beanstalk logs?

Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list. If you have many environments, use the search bar to filter the environment list. In the navigation pane, choose Logs.

Which command is used to view the Elastic Beanstalk events that are using AWS CLI?

The EB CLI is a command line interface for AWS Elastic Beanstalk that provides interactive commands that simplify creating, updating and monitoring environments from a local repository. Use the EB CLI as part of your everyday development and testing cycle as an alternative to the Elastic Beanstalk console.

How do I access my EB engine log?

$ eb logs -cw enable Enabling instance log streaming to CloudWatch for your environment After the environment is updated you can view your logs by following the link: https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs:prefix=/aws/elasticbeanstalk/ environment-name / Printing Status: 2018-07-11 21:05: ...

Can you ssh into Elastic Beanstalk?

You can view a list of Amazon EC2 instances running your AWS Elastic Beanstalk application environment through the Elastic Beanstalk console. You can connect to the instances using any SSH client. You can connect to the instances running Windows using Remote Desktop.


2 Answers

UPDATE: My answer keeps getting upvotes, but things have changed since 2013. It is now easier to tail EB logs—look at posit labs's answer for a simpler way to do it :-).


Original answer:

I had been struggling with this one too. The eb CLI utility does not seem to allow for tailing your application logs currently.

However, you can tail these logs by:

  1. Creating a key pair in the EC2 console (which should give you a .pem file)
  2. Linking your EB instance to this key pair (in the EB console)
  3. Finding the public DNS of your instance in the EC2 console
  4. Connecting to your instance via ssh (`ssh -i [yourpemfile.pem] ec2-user@[your.public.dns]
  5. Tailing your log file. For a Node.js application, that's tail -f /var/log/nodejs/nodejs.log. I don't know what's the equivalent for a Flask application.

(Thanks to Richard Soutar for pointing me in the right direction on this one.)

like image 60
Jorge Aranda Avatar answered Sep 25 '22 13:09

Jorge Aranda


You can use the -g flag to set the log group, then use --stream to stream the results. No need to ssh into a specific machine.

eb logs -g /aws/elasticbeanstalk/yourApp-env/var/log/nodejs/nodejs.log --stream 
like image 28
posit labs Avatar answered Sep 24 '22 13:09

posit labs