Integrate OneAgent on Web App for Containers

Linux only

To monitor Web Apps for Containers in Azure App Services, you need to integrate OneAgent within your containerized application.

Prerequisites

  • Review the list of supported applications and versions
  • Docker version 17.05+
  • OneAgent version 1.155+

Install OneAgent

You can deploy OneAgent either with custom or built-in images.

To integrate OneAgent with the application image

  1. Sign in to Docker with your Dynatrace environment ID as username, and with your PaaS token as password.

    docker login -u <environmentID> <ACTIVEGATE-ADDRESS>
    
  2. Add the following lines of code to the application image after the last FROM command:

    COPY --from=<ADDRESS>/linux/oneagent-codemodules:<TECHNOLOGY> / /
    ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
    

    where:

  • <ADDRESS> is:
    • EnvironmentActiveGate: <ActiveGateaddress:9999>
    • SAAS: {yourenvid}.live.dynatrace.com
    • Managed: {ManagedAddress}
  • <TECHNOLOGY> is: the OneAgent code module required for your application. Valid options are all, java, apache, nginx, nodejs, dotnet, php, go, and sdk. You can specify several code modules, separated by hyphen (-), for example java-go. Including specific technology-support options, rather than support for all technology options, results in a smaller OneAgent package.

What if my Docker image is based on Alpine Linux?
Dynatrace OneAgent supports Alpine Linux based environments.
Use this syntax:

COPY --from=<ACTIVEGATE-ADDRESS>/linux/oneagent-codemodules-musl:<TECHNOLOGY> / /
ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so

Valid options here are all, go, php, java, apache, nginx, and nodejs.

  1. Build your application image.
    Build the Docker image from your Dockerfile to use it in your Kubernetes environment.
$ docker build -t yourapp .

You can monitor your application containers with a different Dynatrace environment.

For OneAgent version 1.139 or higher, if you have an existing application image where you have already added the OneAgent code modules for a specific Dynatrace environment, you can have the OneAgent report to another Dynatrace environment without rebuilding your application image.
For this, you need to make a call to the REST endpoint of your second Dynatrace environment. Don't forget to adapt the respective placeholders <environmentID> and <token>.

$ curl "https://<environmentID>.live.dynatrace.com/api/v1/deployment/installer/agent/connectioninfo?Api-Token=<token>"

In return, you get a JSON object that covers the required information that needs to be passed as an environment variable to the application container.
Make sure you set the environment variables of the application container as described below:

  • DT_TENANT: equals tenantUUID
  • DT_TENANTTOKEN: equals tenantToken
  • DT_CONNECTION_POINT: semi-colon separated list of communicationEndpoints
  1. Optional Configure network zones

    You can configure network zones as an environment variable:

    • DT_NETWORK_ZONE: equals your.network.zone

    See network zones for more information.

Optional Configure a proxy address

In case you run an environment with proxy, you need to set the DT_PROXY environment variable in the application container to pass the proxy credentials to OneAgent.

Note: For Alpine Linux-based containers, you might need to update the wget shipped with the Alpine image to allow for proxy authentication for the download of OneAgent.

Update OneAgent

Each time you want to leverage a new version of Dynatrace OneAgent, you must rebuild your local OneAgent code modules and application image. Any newly started pods from this application image will be monitored with the latest version of OneAgent.

If you've specified a default OneAgent installation version for new hosts and applications using OneAgent update settings, your Web Apps will be automatically monitored by the defined default version of OneAgent.

Uninstall OneAgent

To uninstall OneAgent from application-only monitoring, remove references from your application or Docker image and redeploy the application.

  1. Remove these two lines of code from the application image.
COPY --from=<ACTIVEGATE-ADDRESS>/linux/oneagent-codemodules:<TECHNOLOGY> / /
ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
  1. Rebuild the application image.
$ docker build -t yourapp .