How do I deploy Dynatrace OneAgent as a Docker container?

To monitor applications that run in Docker containers, just run Dynatrace OneAgent on the host—either as a separate container or by installing Dynatrace OneAgent on the host. Please note that you don’t need to embed OneAgent into any of your application images or inherit it from a special base image.

This topic explains how to run OneAgent as a Docker container as an alternative to the normal Linux installation-script approach.

Before you begin

What you’ll need:

  • Dynatrace environment credentials

Note: Your Docker environment must allow your OneAgent container to run in privileged mode.

Locate your Dynatrace environment credentials

The first step is to get your Dynatrace environment ID and token. This information is presented to you during Dynatrace OneAgent installation.

  1. From your Dynatrace home dashboard, open the menu and select Deploy Dynatrace.
  2. Click Start installation and select Linux.
  3. Locate your environment ID and token, as shown below.

Run Dynatrace OneAgent as a Docker container

To run Dynatrace OneAgent as a Docker container you need to issue the following docker run command on all your Docker hosts:

$ docker run -d --restart=unless-stopped --privileged=true --pid=host --net=host --ipc=host -v /:/mnt/root dynatrace/oneagent TENANT=REPLACE_WITH_YOUR_ENVIRONMENT_ID TENANT_TOKEN=REPLACE_WITH_YOUR_TOKEN SERVER=REPLACE_WITH_YOUR_CONNECTION_ENDPOINT

Be sure to replace all REPLACE_WITH placeholders in the command with the respective information explained above. The connection endpoint in REPLACE_WITH_YOUR_CONNECTION_ENDPOINT is https://REPLACE_WITH_YOUR_ENVIRONMENT_ID.live.dynatrace.com. If you’re using Dynatrace Managed, the connection endpoint for your Managed cluster is https://<YourManagedServerURL>/e/REPLACE_WITH_ENVIRONMENT_ID.

Using a container orchestration tool

If you use a container orchestration tool, your orchestrator can deploy the Dynatrace OneAgent container for you. The example snippets below show you how to take advantage of orchestration tools in deploying Dynatrace OneAgent to all your nodes.

Run Dynatrace OneAgent with Mesos/Marathon

To monitor all your apps running in a Mesos cluster with Dynatrace, it’s recommended that you (1) deploy Dynatrace OneAgent on all Mesos agent nodes (formally known as “Mesos slaves”) by means of a Marathon app deployment, and (2) install Dynatrace OneAgent on the Mesos master nodes, as explained below:

Deploy Dynatrace OneAgent on Mesos agent nodes

If you’re using DC/OS to manage your Mesos cluster, you can take advantage of the Dynatrace package in the DC/OS universe. The universe package will automatically deploy Dynatrace to all your Mesos agent nodes.

If you’re not using DC/OS, you can run Dynatrace OneAgent as a Marathon app by following this example:

$ cat <<- EOF > dynatrace-oneagent.json
{
  "id": "dynatrace-oneagent",
  "cpus": 0.1,
  "mem": 256,
  "instances": REPLACE_WITH_NUMER_OF_NODES,
  "constraints": [["hostname", "UNIQUE"], ["hostname", "GROUP_BY"]],
  "container": {
    "type": "DOCKER",
    "volumes": [
      {
        "containerPath": "/mnt/root",
        "hostPath": "/",
        "mode": "RW"
      }
    ],
    "docker": {
      "image": "dynatrace/oneagent",
      "forcePullImage": true,
      "network": "HOST",
      "privileged": true,
      "parameters": [
        { "key": "pid", "value": "host" },
        { "key": "ipc", "value": "host" }
      ]
    }
  },
  "args": [
    "TENANT=REPLACE_WITH_YOUR_ENVIRONMENT_ID",
    "TENANT_TOKEN=REPLACE_WITH_YOUR_TOKEN",
    "SERVER=REPLACE_WITH_YOUR_CONNECTION_ENDPOINT"
  ]
}
EOF

Be sure to replace all REPLACE_WITH placeholders in the dynatrace-oneagent.json file with the respective information explained above. The connection endpoint in REPLACE_WITH_YOUR_CONNECTION_ENDPOINT is https://REPLACE_WITH_YOUR_ENVIRONMENT_ID.live.dynatrace.com. If you’re using Dynatrace Managed, the connection endpoint for your Managed cluster is https://<YourManagedServerURL>/e/REPLACE_WITH_ENVIRONMENT_ID.

Now send an HTTP POST request to the Mesos master leader to deploy the Marathon app with Dynatrace OneAgent.

$ curl -X POST -H "Content-Type: application/json" http://your-mesos-master:8080/v2/apps -d@dynatrace-oneagent.json

Deploy Dynatrace OneAgent on Mesos master nodes

Marathon doesn’t allow you to deploy apps to master nodes (except nodes that are tagged as both master and agent). This is why you need to install Dynatrace OneAgent on all Mesos master nodes (that aren’t additionally configured as Mesos agents) manually. Please use the default Linux installer for this.

Run Dynatrace OneAgent with Kubernetes

Before you begin

What you’ll need:

  • kubectl CLI

To monitor all your apps running in a Kubernetes cluster with Dynatrace, it’s recommended that you (1) deploy Dynatrace OneAgent on all Kubernetes nodes (previously known as “minions”) by means of a DaemonSet, and (2) install Dynatrace OneAgent on the Kubernetes master nodes.

$ cat <<- EOF > dynatrace-oneagent.yaml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: dynatrace-oneagent
spec:
  template:
    metadata:
      labels:
        run: dynatrace-oneagent
    spec:
      hostPID: true
      hostIPC: true
      hostNetwork: true
      volumes:
      - name: host-root
        hostPath:
          path: /
      containers:
      - name: dynatrace-oneagent
        image: dynatrace/oneagent
        args:
        - "TENANT=REPLACE_WITH_YOUR_ENVIRONMENT_ID"
        - "TENANT_TOKEN=REPLACE_WITH_YOUR_TOKEN"
        - "SERVER=REPLACE_WITH_YOUR_CONNECTION_ENDPOINT"
        volumeMounts:
        - mountPath: /mnt/root
          name: host-root
        securityContext:
          privileged: true
EOF

Be sure to replace all REPLACE_WITH placeholders in the dynatrace-oneagent.yaml file with the respective information explained above. The connection endpoint in REPLACE_WITH_YOUR_CONNECTION_ENDPOINT is https://REPLACE_WITH_YOUR_ENVIRONMENT_ID.live.dynatrace.com. If you’re using Dynatrace Managed, the connection endpoint for your Managed cluster is https://<YourManagedServerURL>/e/REPLACE_WITH_ENVIRONMENT_ID.

Deploy the DaemonSet

$ kubectl create -f dynatrace-oneagent.yaml

The command above runs Dynatrace OneAgent on all Kubernetes worker nodes. You may also want to run Dynatrace OneAgent on the master nodes. Please use the default Linux installer for this.

Custom install with command line parameters

For details, see How do I custom install using command line parameters?

Supported technologies and limitations

Running Dynatrace OneAgent as a Docker container gives you full-stack visibility into your complete containerized environment. This includes deep monitoring for supported applications, services and databases.

Deep monitoring for native (i.e., non-containerized) processes on the host is disabled. Also, log analytics functionality doesn’t have access to logs stored at the Docker-host level, including logs gathered by the Docker JSON logging driver.