Is it possible to watch (tail) the logs from an app hosted on Elastic Beanstalk from the command line?
I know this is possible in Heroku using heroku logs -t, but am unsure if there is a way to do this with Beanstalk. If not, any suggestions or tips on how to best manage the logs?
You can ssh to Elastic Beanstalk instance and tail any log. Alternatively, you can publish logs to S3.
For example, the following logs are available for Python environment:
/opt/python/log/httpd.out
/var/log/httpd/error_log
/var/log/cfn-hup.log
/opt/python/log/supervisord.log
/var/log/eb-tools.log
/var/log/httpd/access_log
/var/log/eb-cfn-init-call.log
/var/log/eb-publish-logs.log
/var/log/cfn-init.log
You can find the list of logs available for your environment in web console: Logs > Snapshot Logs > View log file
You will be better off using services like loggly and splunk. You can live watch the logs from multiple server simultaneously and live in the browser itself.
There are free plans also available.
Related
Pardon me if my question sounds stupid, but I've been cracking my brain on this for quite a while, obviously its my first time deploying and i'm a beginner.
I've followed this tutorial (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_rails.html) to deploy my rails app to elastic beanstalk. Everything is successful, eb deploy is successful, eb open opens my application in the terminal(w3m) too.
BUT what am I suppose to do next? I mean
Am i suppose to do anything with the 'upload and deploy' button on Elastic Beanstalk Console? Currently its at Sample Application.
I've tried aws elasticbeanstalk create-application-version --application-name my-application --version-label v2 --source-bundle S3Bucket=(bucket name),S3Key=(zip file)
but in return I get A client error (InvalidParameterCombination) occurred when calling the CreateApplicationVersion operation: Unable to download from S3 location (Bucket: name of bucket Key: name of zip file). Reason: Moved Permanently
What am I suppose to do at the hosted zones at Route 53? I put type: CNAME and value as the url in elastic beanstalk console, and obviously going to my domain says 'Congratulations Your first AWS Elastic Beanstalk Ruby Application is now running on your own dedicated environment in the AWS Cloud' since 'upload and deploy' is at sample application.
OR is my thought process all wrong? Hope someone can enlighten me and tell me what to do. I just need to deploy my web app to my own domain. Thanks in advance.
I don't know if this is useful, the message after eb deploy:
Creating application version archive "(name of app)".
Uploading (name of app).zip to S3. This may take a while.
Upload Complete.
INFO: Environment update is starting.
INFO: Deploying new version to instance(s).
INFO: Environment health has transitioned from Ok to Info. Command is executing on all instances.
INFO: New application version was deployed to running EC2 instances.
INFO: Environment update completed successfully.
Okay, I feel dumb.
I just have to type eb status --verbose into the terminal, copy and paste the CNAME given into Route 53 hosted zone.
My problem is similar to AWS: None of the Instances are sending data but has a slightly different error message.
I have a Rails application running on ElasticBeanstalk, and it appears to be running correctly. Periodically, Enhanced Health Monitoring sends me error messages such as:
Environment health has transitioned from Ok to Degraded. 20.0 % of the
requests are failing with HTTP 5xx.
where the percentage varies up to 100%. Even though I've made no changes, a minute later I get a followup message telling me that everything is back to normal:
Environment health has transitioned from Degraded to Ok.
I've downloaded the full logs from ElasticBeanstalk but I don't know exactly where to look (there are around 20 different log files in various directories).
I'm currently using the free AWS tier with the smallest instances of database, server, etc. Could this be the cause? Which of the log files should I be looking in, and what should I be looking for?
I run rails apps on Elastic Beanstalk and have found it helpful to think about Beanstalk as a computer (in this case an Amazon EC2 instance) running your rails app and a web server (either Passenger or Puma). When you get a 500 error, it could be because your rails app didn't properly deploy–in which case Passenger or Puma will return an error—or your app is deployed properly but encountered an error just like it might on your local machine.
In either case, to diagnose an error, download the full logs from your AWS console (open the correct app environment and then choose Logs > Request Logs > Full logs > Download). Deployment errors are harder to diagnose, but I recommend starting by looking in var-XX/logs/log/eb-activity.log. I suspect your error is coming from your rails app itself, in which case I recommend looking in var-XX/app/support/logs/passenger.log and production.log. To find a 500 error, search for "500 Internal" and then treat the error like you would any other rails error.
You can go to the EC2 instance and run the application just like you would run on your local machine and see the logs.
You can ssh into your EC2 instance using the command eb ssh and go to /opt/python/ directory (It will be different for Ruby or other programming languages).
/opt/python/run is the directory where you will find the version of your application which is run from the EC2 instance. Look for the directory venv and app inside run directory.
Note: The above folder structure is for Python but a similar folder structure post deployment can be found for any other programming language. Just look for the standard directory structure for the deployment environment for your programming language.
For Python:
/opt/python: Root of where you application will end up.
/opt/python/current/app: The current application that is hosted in the environment.
/opt/python/on-deck/app: The app is initially put in on-deck and then, after all the deployment is complete, it will be moved to current. If you are getting failures in your container_commands, check out out the on-deck folder and not the current folder.
/opt/python/current/env: All the env variables that eb will set up for you. If you are trying to reproduce an error, you may first need to source /opt/python/current/env to get things set up as they would be when eb deploy is running.
/opt/python/run/venv: The virtual env used by your application; you will also need to run source /opt/python/run/venv/bin/activate if you are trying to reproduce an error.
I know it is a little late but I wanted to comment the trick I use to find the error, I use to connect via ssh and then, once in the app I try to enter "rails console" It uses to fail, but it shows normally the error you´re making. This little trick saved my life several times. Hope it helps!
I have a rails app on AWS Elastic Beanstalk. I process background tasks using delayed_job. I set up an eb worker instance to handle this. It works but shows as failed (red) in the dashboard. I believe this is because of the following error that I get every few seconds:
error: AWS::SQS::Errors::AccessDenied: Access to the resource https://sqs.us-west-2.amazonaws.com/xxx...xxxx is denied
I tried to remove sqs by means of the following to no avail:
services:
sysvinit:
aws-sqsd:
enabled: false
ensureRunning: false
How do I stop sqs? Ideally it would never be installed in the first place. If I can't modify the install configuration is there a way to prevent this error from affecting the status of my environment?
You are launching a worker tier environment. That is why SQS is being created for your environment. You should launch a "Web Server" environment if you do not want to launch a worker environment. Worker Tier environment in Elastic Beanstalk allows you to poll messages from an SQS queue periodically.
Read more about worker tier environments here:
http://aws.amazon.com/blogs/aws/background-task-handling-for-aws-elastic-beanstalk/
Read more about environment tiers here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html
If you want to use a Worker Tier environment with SQS enabled you can get rid of the AccessDenied exception by giving access to the IAM instance profile to access SQS as explained here:
https://stackoverflow.com/a/24880344/161628
I have an existing app that runs fine on localhost. I tried to deploy it to AWS Elastic Beanstalk today via the step-by-step instructions on this page
After using git aws.push to deploy it onto AWS, I wait for the status of the environment to go to green, and try to access the url it gives me. I get a timeout error after a long while of waiting.
I know this is really not much to go off of, but I'm equally stumped. Is there some kind of server side error log or console log (similar to what I see when I 'rails s' on my computer) so I can see what the AWS environment is writing out? I'm not even sure where to start debugging here.
Your first step is to snapshot your logs from the logs tab of your elastic beanstalk's environment you deployed to. This will give you a snapshot of the recent log activity. If you do need to ssh into the EC2 instance that backs your Elastic Beanstalk instance, it's not immediately evident how to do that. You first need to generate a key pair and download it something like my-key.pem. Then associate that key with the Elastic beanstalk application by editing the configuration and on the first tab, add my-key (note it's just the name, not the actual key). To ssh into your EC2 instance you use ssh -i /path/to/my-key.pem ec2-user#
You get the ec2 public url from the ec2 console. Hope all this helps.
First you'll need to ssh into your server
https://stackoverflow.com/a/4921866/274695
Then, you can look your application logs (passenger.log, production.log) at /var/app/support/logs/
I have one Rails instance and another Node.js instance. The plan is to publish information from the Rails project using Redis's pubsub and subscribe by the Node.js program. The node.js program will publish the information to other clients through web sockets (or long polls).
The whole thing is working perfectly while deployed in combination of remote linux machines. On Heroku, Redis To Go is added as an add-on with the Rails instance. Redis can be connected and working fine from this instance.
But I am not getting how to reach to this Redis add-on from the Node.js instance. I've added REDISTOGO_URL from the environment of Rails instance to the environment of Node.js, but it's not working. Sample errors I'm getting (from logs and REPL) are
redis.set("a","b");
==> Error: Connection in pub/sub mode, only pub/sub commands may be used
redis.psubscribe('*');
==> false
Can somebody please show me a way how to accomplish this?
Yes, all you have to do is set the heroku config value similar to:
'heroku config:add REDISTOGO_URL=[your redis togo url]'
Heroku will then add your config var and restart your app.
You can check to make sure it's added correctly by doing a 'heroku config' on both repositories and comparing them.