# How to forward your Heroku logs to AWS Cloudwatch for free
Oct 16, 2016 1 minute readHeroku is a great platform to run apps with little infrastructure involvement. Most of the time, you just push your code and you get a website up and running in seconds. Heroku even supports third party addons for those times when extra functionality is required. However, I could not find any addon to send my application logs to AWS Cloudwatch. The only logical solution was to build my own AWS Cloudwatch log forwarder.
How to forward the logs to AWS Cloudwatch?
The following steps are for node based apps. If you have a Heroku app made in something else drop me a line and I’ll help you set it up.
Step 1: Have a deployed NodeJs application in Heroku. How?
Step 2: Get your AWS credentials
Step 3: Setup the following Heroku environment variables
heroku config:set AWS_REGION='us-east-1'
heroku config:set AWS_ACCESS_KEY_ID='XXXXXXXXXXXXXXX'
heroku config:set AWS_SECRET_ACCESS_KEY='XXXXXXXXXXXXXXX'
Step 4: Install aws-cloudwatch-forwarder on your project
npm i aws-cloudwatch-forwarder --save
Step 5: Use it in your package.json
Change the start
script in your package.json
in a similar way to this:
"start": "aws-cloudwatch-forwarder 'node web.js'"