How to forward your Heroku logs to AWS Cloudwatch for freeOct 16, 2016 1 minute read
Heroku 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.
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
start script in your
package.json in a similar way to this:
"start": "aws-cloudwatch-forwarder 'node web.js'"