是否有用于从AWS Elastic Beanstalk尾部日志的CLI

Jon*_*han 37 logging amazon-elastic-beanstalk

是否有用于从Elastic Beanstalk应用程序中拖尾日志的CLI实用程序.特别是一个python烧瓶应用程序.

您可以使用他们的eb CLI获取快照......

eb logs
Run Code Online (Sandbox Code Playgroud)

但我想做(类似于heroku提供的)......

eb logs --tail
Run Code Online (Sandbox Code Playgroud)

有没有人完成这个?

谢谢!


一些参考:

Jor*_*nda 25

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.)

  • `eb ssh`允许跳过1-4步并直接进入你正在运行的实例之一 (11认同)

pos*_*abs 10

您可以使用该-g标志设置日志组,然后使用--stream该流来传输结果.无需ssh到特定的机器.

eb logs -g /aws/elasticbeanstalk/yourApp-env/var/log/nodejs/nodejs.log --stream
Run Code Online (Sandbox Code Playgroud)


ere*_*ite 8

现在这很简单:

eb logs --stream
Run Code Online (Sandbox Code Playgroud)

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-logs.html

(我意识到posit lab的答案已经包含了该--stream选项,但是我会继续浏览该答案,因为我想查看所有日志,而不仅仅是一组日志。而且如果我的记忆力更好,我就不必保持谷歌搜索相同的问题并结束搜索在同一地方。)

  • 可能需要先运行“eb logs --cloudwatch-logs enable” (2认同)
  • 你好!我通过调用“eb log --stream”获得输出,但当新日志条目进入时它不会自动更新。我必须再次运行该命令才能查看新条目。有什么线索可能是错误的吗? (2认同)

tar*_*yol 6

您可能不需要EB日志,请尝试eb ssh先再

tail -f /var/log/*
Run Code Online (Sandbox Code Playgroud)