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
Solution 1:
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:
- Creating a key pair in the EC2 console (which should give you a
.pem
file) - Linking your EB instance to this key pair (in the EB console)
- Finding the public DNS of your instance in the EC2 console
- Connecting to your instance via ssh (`ssh -i [yourpemfile.pem] ec2-user@[your.public.dns]
- 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.)
Solution 2:
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