Deploy OneAgent on Kubernetes for application-only monitoring

To deploy OneAgent on Kubernetes for application-only monitoring, read the instructions provided below.

Before you begin

You'll need to

Generate PaaS token

The first step is to get your environment ID and PaaS token for your Dynatrace environment.

Integrate OneAgent into application images

The following steps explain how to integrate OneAgent into a binary build with a Dockerfile.

Define variables with optional default values using ARG instructions.

ARG DT_API_URL="https://<environmentID>.live.dynatrace.com/api"
ARG DT_API_TOKEN="<token>"
ARG DT_ONEAGENT_OPTIONS="flavor=default&include=<technology1>&include=<technology2>"
ENV DT_HOME="/opt/dynatrace/oneagent"

Notes:

  1. Replace <environmentID> with your Dynatrace environment ID. If you’re using Dynatrace Managed, you need to provide your Dynatrace Server URL (https://<YourDynatraceServerURL>/e/<environmentID>/api). Replace <token> with the PaaS token mentioned above.

  2. Technology support is enabled via include parameters. Valid options for flavor=default are all, java, apache, nginx, nodejs, dotnet, php and go. Including specific technology-support options, rather than support for all technology options, results in a smaller OneAgent package.

Add the following commands to your current Dockerfile to integrate OneAgent and activate instrumentation of your application.

ARG DT_API_URL="https://<environmentID>.live.dynatrace.com/api"
ARG DT_API_TOKEN="<token>"
ARG DT_ONEAGENT_OPTIONS="flavor=default&include=<technology1>&include=<technology2>"
ENV DT_HOME="/opt/dynatrace/oneagent"
RUN mkdir -p "$DT_HOME" && \
    wget -O "$DT_HOME/oneagent.zip" "$DT_API_URL/v1/deployment/installer/agent/unix/paas/latest?Api-Token=$DT_API_TOKEN&$DT_ONEAGENT_OPTIONS" && \
    unzip -d "$DT_HOME" "$DT_HOME/oneagent.zip" && \
    rm "$DT_HOME/oneagent.zip"
ENTRYPOINT [ "/opt/dynatrace/oneagent/dynatrace-agent64.sh" ]
CMD [ "executable", "param1", "param2" ] # the command of your application, e.g. java

Note: The commands above that use wget and unzip may fail if they aren't provided by the base image.

Build your application image

Build the Docker image from your Dockerfile to use it in your Kubernetes environment:

$ docker build -t yourapp .

Note: You can monitor your application containers with a different Dynatrace environment. To do this, read the instructions below: