• Home
  • Setup and configuration
  • Set up Dynatrace on cloud platforms
  • Microsoft Azure
  • Integrate OneAgent on App Service for Linux and containers

Integrate OneAgent on App Service for Linux and containers

Linux only

To monitor App Services on Linux and containers, you need to integrate OneAgent within your containerized application.

Prerequisites

  • Create a PaaS Token.
  • 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, you have two options: add the OneAgent installer to the Dynatrace Docker image, or prepare your own Docker image installer. See below for instructions on each of these options.

Option 1: Add the OneAgent installer to the Dynatrace Docker image

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

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

    bash
    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:

    bash
    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.

  3. Build your application image.

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

    bash
    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>.

    bash
    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.

  4. 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.

  5. Restart the web app two times:

    • Restart the web app once to initialize the OneAgent install script.
    • Restart the web app a second time to start OneAgent on the host.

Option 2: Prepare your own Docker image installer

  1. Add the two following lines to your Dockerfile.

    • For SaaS deployments:

      bash
      RUN curl -o /tmp/installer.sh -s https://<your-environment-ID>.live.dynatrace.com/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=<DT_PAAS_TOKEN>&arch=x86 && sh /tmp/installer.sh /home ENV LD_PRELOAD /home/dynatrace/oneagent/agent/lib64/liboneagentproc.so

      Note: Be sure to replace

      • <your-environment-ID> with your environment ID. See environment ID for details.
      • <DT_PAAS_TOKEN> with your PaaS token. See Prerequisites for details.
    • For Managed deployments:

      bash
      RUN curl -o /tmp/installer.sh -s https://<your-domain>/e/<your-environment-ID>/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=<DT_PAAS_TOKEN>&arch=x86 && sh /tmp/installer.sh /home ENV LD_PRELOAD /home/dynatrace/oneagent/agent/lib64/liboneagentproc.so

      Note: Be sure to replace

      • <your-domain> with your Managed domain.
      • <your-environment-ID> with your environment ID. See environment ID for details.
      • <DT_PAAS_TOKEN> with your PaaS token. See Prerequisites for details.

    What if my Docker image is based on Alpine Linux?
    For Alpine Linux you need to specify &flavor=musl to the end of the URL.

    • Example URL for SaaS deployments: https://<your-environment-ID>.live.dynatrace.com/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=<DT_PAAS_TOKEN>&arch=x86&flavor=musl.
    • Example URL for Managed deployments: https://<your-domain>/e/<your-environment-ID>/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=<DT_PAAS_TOKEN>&arch=x86&flavor=musl.
  2. Build your Docker container with the modified Dockerfile. This sets up the injection.

  3. Restart the web app two times:

    • Restart the web app once to initialize the OneAgent install script.
    • Restart the web app a second time to start OneAgent on the host.

Note: The process will show up in Dynatrace after running the new built version.

  1. Create a resource group and a service plan for the web app where you want to install OneAgent.

  2. Create the web app.

    Example command:

    plaintext
    az webapp create \ --resource-group "$AZURE_RESOURCE_GROUP_NAME" \ --plan "$AZURE_SERVICE_PLAN_NAME" \ --name "$AZURE_APP_NAME" \ --runtime "$RUNTIME" \ --startup-file "$STARTUP_COMMAND"

    where you need to replace

    • $AZURE_RESOURCE_GROUP_NAME, $AZURE_SERVICE_PLAN_NAME, $AZURE_APP_NAME, $RUNTIME with your own values.
    • $STARTUP_COMMAND with "curl -o /tmp/installer.sh -s \"${DT_API_URL}/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=${DT_PAAS_TOKEN}&arch=x86\" && sh /tmp/installer.sh /home && LD_PRELOAD='/home/dynatrace/oneagent/agent/lib64/liboneagentproc.so' <BUILT-IN_IMAGE_STARTUP_COMMAND>". For <BUILT-IN_IMAGE_STARTUP_COMMAND> select your built-in image startup command value, as shown in built-in images in Microsoft documentation.
  3. Restart the web app two times:

    • Restart the web app once to initialize the OneAgent install script.
    • Restart the web app a second time to start OneAgent on the host.

For more information on how to create the web app and what values to use, see the Microsoft examples.

Note: We don't recommend using the SKU free plan, as it doesn't provide enough resources for a given application and 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.

When an update is available, restart your application to update 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.

    plaintext
    COPY --from=<ACTIVEGATE-ADDRESS>/linux/oneagent-codemodules:<TECHNOLOGY> / / ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
  2. Rebuild the application image.

    plaintext
    docker build -t yourapp .

To uninstall OneAgent

  1. In Azure Portal, go to your web app > Configuration > General settings.
  2. Remove your startup command (leave Startup Command empty).
  3. Select Save.

Limitations

OneAgent can't be deployed on Azure instances where Azure Application Insights is already set up.

Related topics
  • Microsoft Azure monitoring

    Set up and configure monitoring for Microsoft Azure.

  • OneAgent platform and capability support matrix

    Learn which capabilities are supported by OneAgent on different operating systems and platforms.