Join us at the Dash conference! July 16-17, NYCJoin us at Dash! July 16-17, NYC
Deploy Datadog on AWS Elastic Beanstalk

Deploy Datadog on AWS Elastic Beanstalk

Author David Caplan
/ / /
Published: May 7, 2014

Editor’s note (August 2018): Some of the commands below are specific to Agent 5. See our documentation for more details about this integration. The steps below have been modified for Agent 6 by Datadog user Wim Deblauwe and are available on his blog.

David Caplan @davc is the Chief Technology Officer at SolveBio and runs his own blog,

At SolveBio we use AWS Elastic Beanstalk to manage some of our apps on EC2. Our API for biomedical data is critical for running diagnostic tests, so we like to keep an eye on its performance. We started using Datadog a few weeks ago to help us out with monitoring and metrics, but we ran into some issues getting it to play nicely with Elastic Beanstalk. This article describes how we got it all working together.

How SolveBio uses Elastic Beanstalk

Similar to Heroku, Elastic Beanstalk makes it super easy to deploy various web apps to EC2. At SolveBio, we mostly work with Python and Node.js, so the method described here focuses on those stacks. The Datadog agent is a daemon managed by supervisord, which sends system metrics to Datadog but also works as a statsD proxy.

One kink we initially encountered was that the Datadog agent and Elastic Beanstalk rely on separate installations of supervisord. This confuses the heck out of Elastic Beanstalk. Luckily, getting past this kink is simple. You just have to tell Elastic Beanstalk to stop Datadog before deploying and start it again when you’re done.

Before continuing, make sure you’ve read the Elastic Beanstalk Getting Started Guide and Customizing and Configuring a Python Container.

Deploy the Datadog agent on Elastic Beanstalk

Once your project is all set up for Elastic Beanstalk, create the .ebextensions, .ebextensions/datadog, and .ebextensions/datadog/hooks directories, and pop in the following files:


# .ebextensions/99datadog.config
            command: "chmod +x .ebextensions/datadog/hooks/*"
            test: '[ ! -d /opt/elasticbeanstalk/hooks/appdeploy/post ]'
            command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
            test: '[ ! -d /opt/elasticbeanstalk/hooks/configdeploy/post ]'
            command: "mkdir /opt/elasticbeanstalk/hooks/configdeploy/post"
            command: "cp .ebextensions/datadog/hooks/ /opt/elasticbeanstalk/hooks/appdeploy/pre/"
            command: "cp .ebextensions/datadog/hooks/ /opt/elasticbeanstalk/hooks/appdeploy/post/"
            command: "cp .ebextensions/datadog/hooks/ /opt/elasticbeanstalk/hooks/preinit"
            command: "cp .ebextensions/datadog/hooks/ /opt/elasticbeanstalk/hooks/postinit"
            command: "cp .ebextensions/datadog/hooks/ /opt/elasticbeanstalk/hooks/configdeploy/pre/"
            command: "cp .ebextensions/datadog/hooks/ /opt/elasticbeanstalk/hooks/configdeploy/post/"
            command: "cp .ebextensions/datadog/datadog.repo /etc/yum.repos.d/datadog.repo; yum -y makecache; yum -y install datadog-agent; /etc/init.d/datadog-agent stop"
            test: '[ ! -e /etc/dd-agent/datadog.conf ]'
            command: "sh -c \"sed 's/api_key:.*/api_key: YOUR_API_KEY/' /etc/dd-agent/datadog.conf.example > /etc/dd-agent/datadog.conf\""


name = Datadog, Inc.
baseurl =


# .ebextensions/datadog/hooks/
if [ -e /etc/init.d/datadog-agent ]; then
  /etc/init.d/datadog-agent start


# .ebextensions/datadog/hooks/
if [ -e /etc/init.d/datadog-agent ]; then
  /etc/init.d/datadog-agent stop

Once all the files are in there, commit the changes and then deploy your app using git aws.push. The agent should be installed once the update finishes, and it should also keep working after further deploys to your Elastic Beanstalk instances. We found it helpful to enable SSH login to our instances for debugging.

Now the Elastic Beanstalk monitoring fun begins

Now that we’re up and running, monitoring AWS Elastic Beanstalk with Datadog has already proven to be very helpful. With that said, we’re still getting acquainted with Datadog so I’ll be back in a few weeks to share my thoughts on key AWS Elastic Beanstalk metrics to monitor and any tips and tricks or best practices I’ve gained. In the meantime, if you’d like to gain visibility into your AWS Elastic Beanstalk performance you can .