---
title: AWS Elastic Beanstalk
description: >-
  Simplifies deploying and scaling web applications and services on familiar
  servers.
breadcrumbs: Docs > Integrations > AWS Elastic Beanstalk
---

# AWS Elastic Beanstalk
Integration version1.0.0
## Overview{% #overview %}

AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.

## Setup{% #setup %}

### Installation{% #installation %}

If you haven't already, set up the [Amazon Web Services integration](https://docs.datadoghq.com/integrations/amazon_web_services/) first. To receive Elastic Beanstalk metrics, you must [enable the Enhanced Health Reporting](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced.html) feature for your environment, and configure your environment to [publish enhanced health metrics to CloudWatch](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-cloudwatch.html#health-enhanced-cloudwatch-console).

**Note**: These settings increase your CloudWatch custom metric charges.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **aws.elasticbeanstalk.environment\_health**(gauge)              | [Environment] The health status of the environment. The possible values are 0 (OK) 1 (Info) 5 (Unknown) 10 (No data) 15 (Warning) 20 (Degraded) and 25 (Severe). |
| **aws.elasticbeanstalk.application\_latency\_p\_1\_0**(gauge)    | The average time to complete the fastest 10 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_5\_0**(gauge)    | The average time to complete the fastest 50 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_7\_5**(gauge)    | The average time to complete the fastest 75 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_8\_5**(gauge)    | The average time to complete the fastest 85 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_9\_0**(gauge)    | The average time to complete the fastest 90 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_9\_5**(gauge)    | The average time to complete the fastest 95 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_9\_9**(gauge)    | The average time to complete the fastest 99 percent of requests.*Shown as second*                                                                                |
| **aws.elasticbeanstalk.application\_latency\_p\_9\_9\_9**(gauge) | The average time to complete the fastest 99.9 percent of requests.*Shown as second*                                                                              |
| **aws.elasticbeanstalk.application\_requests\_2xx**(count)       | The number of requests that completed with a 2XX status code.*Shown as request*                                                                                  |
| **aws.elasticbeanstalk.application\_requests\_3xx**(count)       | The number of requests that completed with a 3XX status code.*Shown as request*                                                                                  |
| **aws.elasticbeanstalk.application\_requests\_4xx**(count)       | The number of requests that completed with a 4XX status code.*Shown as request*                                                                                  |
| **aws.elasticbeanstalk.application\_requests\_5xx**(count)       | The number of requests that completed with a 5XX status code.*Shown as request*                                                                                  |
| **aws.elasticbeanstalk.application\_requests\_total**(count)     | The number of requests completed by the instance or environment.*Shown as request*                                                                               |
| **aws.elasticbeanstalk.cpuidle**(gauge)                          | [Instance] The percentage of time the CPU was in the idle state in the last minute.*Shown as percent*                                                            |
| **aws.elasticbeanstalk.cpuiowait**(gauge)                        | [Instance] The percentage of time the CPU was in the iowait state in the last minute.*Shown as percent*                                                          |
| **aws.elasticbeanstalk.cpuirq**(gauge)                           | [Instance] The percentage of time the CPU was in the interrupt request state in the last minute.*Shown as percent*                                               |
| **aws.elasticbeanstalk.cpunice**(gauge)                          | [Instance] The percentage of time the CPU was in the nice state in the last minute.*Shown as percent*                                                            |
| **aws.elasticbeanstalk.cpusoftirq**(gauge)                       | [Instance] The percentage of time the CPU was in the soft interrupt request state in the last minute.*Shown as percent*                                          |
| **aws.elasticbeanstalk.cpusystem**(gauge)                        | [Instance] The percentage of time the CPU was in the system state in the last minute.*Shown as percent*                                                          |
| **aws.elasticbeanstalk.cpuuser**(gauge)                          | [Instance] The percentage of time the CPU was in the user state in the last minute.*Shown as percent*                                                            |
| **aws.elasticbeanstalk.instance\_health**(gauge)                 | [Instance] The health status of the instance.*Shown as instance*                                                                                                 |
| **aws.elasticbeanstalk.instances\_degraded**(count)              | [Environment] The number of instances with Degraded health status.*Shown as instance*                                                                            |
| **aws.elasticbeanstalk.instances\_info**(count)                  | [Environment] The number of instances with Info health status.*Shown as instance*                                                                                |
| **aws.elasticbeanstalk.instances\_no\_data**(count)              | [Environment] The number of instances with no health status data.*Shown as instance*                                                                             |
| **aws.elasticbeanstalk.instances\_ok**(count)                    | [Environment] The number of instances with OK health status.*Shown as instance*                                                                                  |
| **aws.elasticbeanstalk.instances\_pending**(count)               | [Environment] The number of instances with Pending health status.*Shown as instance*                                                                             |
| **aws.elasticbeanstalk.instances\_severe**(count)                | [Environment] The number of instances with Severe health status.*Shown as instance*                                                                              |
| **aws.elasticbeanstalk.instances\_unknown**(count)               | [Environment] The number of instances with Unknown health status.*Shown as instance*                                                                             |
| **aws.elasticbeanstalk.instances\_warning**(count)               | [Environment] The number of instances with Warning health status.*Shown as instance*                                                                             |
| **aws.elasticbeanstalk.load\_average\_1min**(gauge)              | [Instance] The average CPU load over the last minute.                                                                                                            |
| **aws.elasticbeanstalk.load\_average\_5min**(gauge)              | [Instance] The average CPU load over the last five minutes.                                                                                                      |
| **aws.elasticbeanstalk.root\_filesystem\_util**(gauge)           | [Instance] The percentage of disk space in use.*Shown as percent*                                                                                                |

Each of the metrics retrieved from AWS are assigned the same tags that appear in the AWS console, including but not limited to host name, security-groups, and more.

### Events{% #events %}

The AWS Elastic Beanstalk integration does not include any events.

### Service Checks{% #service-checks %}

The AWS Elastic Beanstalk integration does not include any service checks.

## Datadog Agent Configuration{% #datadog-agent-configuration %}

The following steps deploy the Datadog Agent on your Elastic Beanstalk VMs, so they report host metrics in addition to the metrics crawled by the AWS integration. Read [Why should I install the Datadog Agent on my cloud instances?](https://docs.datadoghq.com/agent/guide/why-should-i-install-the-agent-on-my-cloud-instances/) for more information.

Select your installation method to configure the Agent in your Elastic Beanstalk environment:

{% tab title="No containers (Linux)" %}
For a no container setup, install the Datadog Agent in Elastic Beanstalk using [Advanced Environment Customization with Configuration Files](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html) (.ebextensions):

1. Create a folder named `.ebextensions` in the root of your [application source bundle](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-sourcebundle.html).
1. Download [99datadog.config](https://docs.datadoghq.com/config/99datadog.config) and put it in the `.ebextensions` folder.
1. Change the value of `api_key` within the file template for `/etc/datadog-agent/datadog.yaml` with your [Datadog API Key](https://app.datadoghq.com/organization-settings/api-keys).
1. Change the value of `site` in `/etc/datadog-agent/datadog.yaml` to your Datadog region (for example: ) to ensure the Agent sends data to the right Datadog location.
1. Pin a specific Agent version by setting `DD_AGENT_VERSION` under `option_settings` to ensure that all hosts run the same version of the Agent.
1. Deploy your application with the [Elastic Beanstalk Console](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-console-ebextensions), [EB CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-ebcli), or [AWS CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-awscli).

You can add additional Agent settings to `/etc/datadog-agent/datadog.yaml`.

For example, to enable Live Process Monitoring:

```text
process_config:
  enabled: "true"
```

#### Trace collection{% #trace-collection %}

When the application isn't containerized and the Datadog Agent is configured with `99datadog.config`, tracing is enabled without any additional Agent configuration, provided the application is instrumented with the appropriate [tracing library](https://docs.datadoghq.com/tracing/setup/).

For **Java applications running on Tomcat**, download [99datadog-java-apm.config](https://docs.datadoghq.com/config/99datadog-java-apm.config) and add it to your `.ebextensions` folder alongside `99datadog.config`. This file downloads the Datadog Java APM agent and configures Tomcat's JVM options to load it. For other Java application servers (Spring Boot, Jetty, JBoss, and so on), see [Java tracing library setup](https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/java/).

To enable or disable tracing features and other observability products using environment variables, see [Configure APM features on Linux](https://docs.datadoghq.com/tracing/trace_collection/configure_apm_features_linux/).
{% /tab %}

{% tab title="No containers (Windows)" %}
For a no container setup, install the Datadog Agent in Elastic Beanstalk using [Advanced Environment Customization with Configuration Files](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html) (.ebextensions):

1. Create a folder named `.ebextensions` in the root of your [application source bundle](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-sourcebundle.html).
1. Download [99datadog-windows.config](https://docs.datadoghq.com/config/99datadog-windows.config) and move it to the `.ebextensions` folder. Review the sample configuration and make modifications as necessary.
1. In `99datadog-windows.config`, replace the `APIKEY` value with your [Datadog API Key](https://app.datadoghq.com/organization-settings/api-keys).
1. (Optional) If you need to add environment variables, set them in the `00_setup-env1` section of `99datadog-windows.config`. You can remove this section if you do not need to set environment variables.
1. (Optional) If you don't want to enable APM in your environment, remove the `packages.msi.DotnetAPM` section, the `02_setup-APM1` section, and the `03_setup-APM2` section.
1. For **Trace Collection with .NET APM**:
   1. Replace the `packages.msi.DotnetAPM` link with the MSI file (Windows Installer) from the desired version in the [dd-trace-dotnet release notes](https://github.com/DataDog/dd-trace-dotnet/releases).
   1. (Optional) If you need to add environment variables for .NET APM, set them in the `00_setup-env1` section of `99datadog-windows.config`.
1. Deploy your application with the [Elastic Beanstalk Console](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-console-ebextensions), [EB CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-ebcli), or [AWS CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-awscli).

#### Trace collection{% #trace-collection %}

When the application isn't containerized and the Datadog Agent is configured with `99datadog-windows.config`, tracing is enabled without any additional configuration beyond the steps listed in the previous section. For more information on instrumenting tracing, see [Set up Datadog APM](https://docs.datadoghq.com/tracing/setup/).
{% /tab %}

{% tab title="Single container" %}
For a single Docker container setup, install the Datadog Agent in Elastic Beanstalk using [Advanced Environment Customization with Configuration Files](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html) (.ebextensions).

**Note**: This setup requires your API key to be placed in the .ebextensions directory, which is part of the source code. Use [AWS Secret Manager](https://aws.amazon.com/secrets-manager/) or other secret management tooling to protect your API key.

1. Create a folder named `.ebextensions` in the root of your [application source bundle](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-sourcebundle.html).
1. Download [99datadog.config](https://docs.datadoghq.com/config/99datadog.config) and put it in the `.ebextensions` folder.
1. Change the value of `api_key` within the file template for `/etc/datadog-agent/datadog.yaml` with your [Datadog API Key](https://app.datadoghq.com/organization-settings/api-keys).
1. Change the value of `site` in `/etc/datadog-agent/datadog.yaml` to your Datadog region (for example: ) to ensure the Agent sends data to the right Datadog location.
1. Pin a specific Agent version by setting `DD_AGENT_VERSION` under `option_settings` to ensure that all hosts run the same version of the Agent.
1. Deploy your application with the [Elastic Beanstalk Console](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-console-ebextensions), [EB CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-ebcli), or [AWS CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-during.html#configuration-options-during-awscli).

You can add additional Agent settings to `/etc/datadog-agent/datadog.yaml`.

For example, to enable Live Process Monitoring:

```text
process_config:
  enabled: "true"
```

#### Trace collection{% #trace-collection %}

To enable tracing for single Docker containers:

1. Update the `/etc/datadog-agent/datadog.yaml` section in the `99datadog.config` file with `apm_non_local_traffic`, formatted like this:

   ```
   apm_config:
     enabled: "true"
     apm_non_local_traffic: "true"
   ```

1. Set up the tracing libraries to direct traces to the [Gateway IP of the bridge network](https://docs.docker.com/engine/network/tutorials/standalone/#use-the-default-bridge-network), which defaults to `172.17.0.1` from inside the application container. (If you're not sure this is the Gateway IP, run `docker inspect <container id>` to confirm.)

For all languages, set the environment variable `DD_AGENT_HOST` to the Gateway IP. Alternatively, for the languages below, set the host name programmatically using:

##### Python{% #python %}

```python
from ddtrace import tracer

tracer.configure(hostname="172.17.0.1")
```

##### Node.js{% #nodejs %}

```javascript
const tracer = require('dd-trace');

tracer.init({ hostname: "172.17.0.1" });
```

##### Ruby{% #ruby %}

```ruby
require 'ddtrace'

Datadog.configure do |c|
  c.tracer hostname: "172.17.0.1")
end
```

##### Go{% #go %}

```go
package main

import (
    "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

func main() {
  tracer.Start(tracer.WithAgentAddr("172.17.0.1"))
  defer tracer.Stop()

  // ...
}
```

{% /tab %}

{% tab title="Multiple containers" %}
For multiple Docker containers, use the containerized Datadog Agent to monitor Docker usage with a file named `Dockerrun.aws.json`.

A `Dockerrun.aws.json` file is an Elastic Beanstalk—specific JSON file that describes how to deploy a set of Docker containers as an Elastic Beanstalk application. You can use this file for a multicontainer Docker environment. `Dockerrun.aws.json` describes the containers to deploy to each container instance in the environment and the data volumes to create on the host instance for the containers to mount.

A `Dockerrun.aws.json` file can be used on its own or zipped up with additional source code in a single archive. Source code that is archived with `Dockerrun.aws.json` is deployed to container instances and accessible in the `/var/app/current/` directory. Use the `volumes` section of the config to provide mount points for the containers running on the instance and the `mountPoints` section of the embedded container definitions to mount them from the containers.

The following code sample illustrates a `Dockerrun.aws.json` declaring the Datadog Agent. Update the `containerDefinitions` section with your [Datadog API Key](https://app.datadoghq.com/organization-settings/api-keys), tags (optional), and any additional container definitions. If needed, this file can be zipped with additional content as described above. For more info about the syntax of this file, see [Multicontainer Docker configuration](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html).

**Notes**:

- For high resource usage, you may need a higher memory limit.
- To ensure all hosts run the same Agent version, it is recommended to change `agent:7` to a specific minor version of the [Docker image](https://gcr.io/datadoghq/agent).

{% callout %}
# Important note for users on the following Datadog sites: us3.datadoghq.com, app.datadoghq.eu, app.ddog-gov.com



- Set `DD_SITE` to  to ensure the Agent sends data to the right Datadog location.


{% /callout %}

```json
{
    "AWSEBDockerrunVersion": 2,
    "volumes": [
        {
            "name": "docker_sock",
            "host": {
                "sourcePath": "/var/run/docker.sock"
            }
        },
        {
            "name": "proc",
            "host": {
                "sourcePath": "/proc/"
            }
        },
        {
            "name": "cgroup",
            "host": {
                "sourcePath": "/sys/fs/cgroup/"
            }
        }
    ],
    "containerDefinitions": [
        {
            "name": "dd-agent",
            "image": "gcr.io/datadoghq/agent:7",
            "environment": [
                {
                    "name": "DD_API_KEY",
                    "value": "<YOUR_DD_API_KEY>"
                },
                {
                    "name": "DD_SITE",
                    "value": "<YOUR_DD_SITE>"
                },
                {
                    "name": "DD_TAGS",
                    "value": "<SIMPLE_TAG>, <KEY:VALUE_TAG>"
                }
            ],
            "memory": 256,
            "mountPoints": [
                {
                    "sourceVolume": "docker_sock",
                    "containerPath": "/var/run/docker.sock",
                    "readOnly": false
                },
                {
                    "sourceVolume": "proc",
                    "containerPath": "/host/proc",
                    "readOnly": true
                },
                {
                    "sourceVolume": "cgroup",
                    "containerPath": "/host/sys/fs/cgroup",
                    "readOnly": true
                }
            ]
        }
    ]
}
```

#### Creating the environment{% #creating-the-environment %}

Once the container definition is ready, ship it to Elastic Beanstalk. For specific instructions, see [Multicontainer Docker Environments](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecstutorial.html) in the AWS Elastic Beanstalk documentation.

#### DogStatsD{% #dogstatsd %}

To collect custom metrics from your application container using DogStatsD in the [Multicontainer Docker Environment](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecstutorial.html), add the following to your `Dockerrun.aws.json`:

1. Add the environment variable `DD_DOGSTATSD_NON_LOCAL_TRAFFIC` under the `dd-agent` container:

   ```json
   {
     "name": "DD_DOGSTATSD_NON_LOCAL_TRAFFIC",
     "value": "true"
   }
   ```

1. Add a link to the `dd-agent` container under your application container:

   ```text
   "links": [ "dd-agent:dd-agent"]
   ```

See [DogStatsD and Docker](https://docs.datadoghq.com/integrations/faq/dogstatsd-and-docker/) for additional information.
{% /tab %}

#### Multiple Docker containers{% #multiple-docker-containers %}

1. In the same `Dockerrun.aws.json` as the application, add a Datadog Agent container using the `datadog/agent` image. Add the following:
   - Under the `portMappings` section, add a `hostPort` 8126 with `containerPort` 8126.
   - Under the `environment` section, set`DD_APM_ENABLED` and `DD_APM_NON_LOCAL_TRAFFIC` to `true`.
1. Under your application container, which was instrumented with the [tracing library setup](https://docs.datadoghq.com/tracing/setup/), add the following:
   - Under the `environment` section, add an environment variable called `DD_AGENT_HOST` to the name of the Datadog Agent container.
   - Under the `links` section, set the Agent container to be used as an environment variable.

An example can be seen below:

```text
 "containerDefinitions": [    {
      "name": "dd-agent",
      "image": "datadog/agent:latest",
      "environment": [
          {
              "name": "DD_API_KEY",
              "value": "<api key>"
          },
          {
              "name": "DD_APM_ENABLED",
              "value": "true"
          },
          {
             "name": "DD_APM_NON_LOCAL_TRAFFIC",
             "value": "true"
          },
         # any other environment variables needed
      ],
      "portMappings": [
        {
          "hostPort": 8126,
          "containerPort": 8126
        }
      ],
      "memory": 256,
      "mountPoints": [
          # any mountpoints needed
         }
      ]
    },
    {
      "name": "application-container",
      "image": "<application image name>",
      "environment": [
        {
          "name": "DD_AGENT_HOST",
          "value": "dd-agent",
          # any other environment variables needed
        }
      ],
      "links": [
        "dd-agent:dd-agent"
      ],
```

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

## Further Reading{% #further-reading %}

- [Deploy Datadog on AWS Elastic Beanstalk](https://www.datadoghq.com/blog/deploy-datadog-aws-elastic-beanstalk)
