• Home
  • Deploy Dynatrace
  • Set up Dynatrace on cloud platforms
  • Microsoft Azure
  • Integrations
  • Monitor Azure App Service
  • Integrate on App Service for Linux and containers

Integrate on App Service for Linux and containers

Linux only

App Service on Linux supports two scenarios:

  • Bring your own code

    In the code scenario, App Service provides a base container that is maintained by the platform.

    This container targets:

    • A development framework, such as .NET Core, PHP, or Node.js
    • A version of that framework, such as .NET Core 3.0 or .NET Core 3.1

    Follow the steps presented in Built-in image

  • Bring your own container

    In the container scenario, App Service provides a host where a custom container provided by the customer can execute.

    For details on differences between the two scenarios, see Things you should know: Web Apps on Linux.

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

    Follow the steps presented in Custom image

Integrate Dynatrace on built-in image

Azure App Service for Linux allows you to customize its base container at runtime using a startup script or script command that must be executed in a bash shell or Azure Cloud Shell. The script can be configured in multiple ways:

Set startup script command/file at creation time using Azure CLI

shell
az webapp create -n <my-app> -g <my-resourcegroup> -p <my-appservice-plan> --runtime <runtime-tag> --startup-file <startup-script/command>

Set script command/file at creation time for an existing App Service

shell
az webapp config set -n <my-app> -g <my-resourcegroup> --startup-file <startup-script/command>

Set script command/file using ARM template

Use the appCommandLine property of your ARM template to set the startup script/command.

json
{ "acrUseManagedIdentityCreds": false, "acrUserManagedIdentityId": null, "alwaysOn": false, "apiDefinition": null, "apiManagementConfig": null, "appCommandLine": "<startup-script/command>", "appSettings": null, "autoHealEnabled": false, "autoHealRules": null, "autoSwapSlotName": null, ...

Set startup script command/file in the Azure portal

AppService Linux Portal Startup

Script or command?

Startup scripts require that you package the script along with your application. If you don't want to have this dependency, use startup commands.

The script/command is executed within the container init script, which is implemented differently on each technology stack.

For details on startup commands, see the Azure App Service for Linux documentation on What are the expected values for the Startup File section when I configure the runtime stack?

Integrate Dynatrace using a startup script/command

To integrate Dynatrace, run the command below.

bash
wget -O /tmp/installer.sh -q "$DT_ENDPOINT/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=$DT_API_TOKEN&flavor=$DT_FLAVOR&include=$DT_INCLUDE" && sh /tmp/installer.sh && LD_PRELOAD="/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so" $START_APP_CMD

Alternatively, you can use the calling-only script below that works for all Linux images:

bash
#!/bin/sh wget -O /tmp/installer.sh -q "$DT_ENDPOINT/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=$DT_API_TOKEN&flavor=$DT_FLAVOR&include=$DT_INCLUDE" sh /tmp/installer.sh LD_PRELOAD="/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so" $START_APP_CMD

Set/replace the following parameters of the script:

ParameterDescription

$DT_ENDPOINT

Your Dynatrace API server endpoint. Use either your environment cluster endpoint or an ActiveGate address.

$DT_API_TOKEN

API Token to access the Dynatrace REST API. Create an API Token with the InstallerDownload scope.

$DT_FLAVOR

Configure the required architecture:

  • default for standard, glibc-based Linux images
  • musl for Alpine Linux–based images

Note: Most built-in images use standard Linux-based images, with the exception of Apache Tomcat. You may need to review the Dockerfile of the used runtime stack if it uses an Alpine-based image.

$DT_INCLUDE

Configure required code modules, depending on the used technology stack.

  • all includes all available OneAgent code modules (java, apache, nginx, nodejs, dotnet, php, go, sdk), but it increases download package size
  • Alternatively, choose an identifier appropriate to your application stack, such as java, dotnet, nodejs, or php

For details, see API documentation

$START_APP_CMD

The actual command to start your application. What are the expected values for the Startup File section when I configure the runtime stack?

Note: If you use a shell other than bash, make sure to adapt the script appropriately to the shell's character escape requirements.

Example: Integrate into a node.js application using Azure CLI within a bash shell

Configure the startup command

Restart the web app twice

Configure the startup command

bash
RESOURCE_GROUP="my-appservice-test" APPSVC="my-linux-webapp" DT_API_URL="https://XXXXXX.live.dynatrace.com" DT_API_TOKEN="XXXXXX" DT_FLAVOR="musl" DT_INCLUDE="nodejs" START_APP_CMD="pm2 start index.js --no-daemon" STARTUP_CMD="wget -O /tmp/installer.sh -q \"$DT_API_URL/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=$DT_API_TOKEN&flavor=$DT_FLAVOR&include=$DT_INCLUDE\" && sh /tmp/installer.sh && LD_PRELOAD='/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so' $START_APP_CMD" az webapp config set --resource-group $RESOURCE_GROUP --name $APPSVC --startup-file "$STARTUP_CMD"

Restart the web app twice

After you configure the startup command, restart the web app two times:

  • Restart once to initialize OneAgent installation
  • Restart again to start OneAgent instrumenting your application

Integrate Dynatrace on custom image

To integrate OneAgent with the application image, you have two options:

  • Integrate the OneAgent image layer provided by Dynatrace
  • Download OneAgent artifacts at image build-time from Dynatrace REST API

Option 1: Integrate using Dynatrace offered OneAgent image layer

This option requires that you have Docker v17.05+ installed on your computer.

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

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

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

    Replace the following placeholders in the template

    ParameterDescription

    <ADDRESS>

    Your Dynatrace registry endpoint. Use either your environment cluster endpoint or an ActiveGate address.

    <TECHNOLOGY>

    Configure required code modules, depending on the used technology stack.

    • all includes all available OneAgent code modules (java, apache, nginx, nodejs, dotnet, php, go, sdk), but it increases download package size
    • Alternatively, choose an identifier appropriate to your application stack, such as java, dotnet, nodejs, or php

    For details, see the API documentation.

    What if my Docker image is based on Alpine Linux?

    Dynatrace OneAgent supports Alpine Linux–based environments. To use an Alpine Linux compatible OneAgent, use image name oneagent-codemodules-musl (as shown in the adapted template below) instead of oneagent-codemodules.

    bash
    COPY --from=<ADDRESS>/linux/oneagent-codemodules-musl:<TECHNOLOGY> / / ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
  3. Build your application image.

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

    bash
    docker build -t yourapp .
  4. Restart the web app two times:

    • Restart once to initialize the OneAgent install script
    • Restart again to start OneAgent on the host

Option 2: Integrate using installer script from Dynatrace REST API

  1. Add the following two lines to your Dockerfile.

    bash
    RUN wget -O /tmp/installer.sh -q "<DT_ENDPOINT>/api/v1/deployment/installer/agent/unix/paas-sh/latest?Api-Token=<DT_API_TOKEN>&flavor=<DT_FLAVOR>&include=<DT_INCLUDE>" && sh /tmp/installer.sh ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so

    Replace the following parameters in the above template:

    ParameterDescription

    <DT_ENDPOINT>

    Your Dynatrace API endpoint. Use either your environment cluster endpoint or an ActiveGate address.

    <DT_API_TOKEN>

    API Token to access the Dynatrace REST API. Create an API Token with the InstallerDownload scope.

    <DT_FLAVOR>

    Configure the required architecture.

    • default for standard, glibc-based Linux images
    • musl for Alpine Linux–based images

    <DT_INCLUDE>

    Configure required code modules, depending on the used technology stack.

    • all includes all available OneAgent code modules (java, apache, nginx, nodejs, dotnet, php, go, sdk), but it increases download package size
    • Alternatively, choose an identifier appropriate to your application stack, such as java, dotnet, nodejs, or php

    For details, see the API documentation.

  2. Build your application image.

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

    bash
    docker build -t yourapp .
  3. Restart the web app two times:

    • Restart once to initialize the OneAgent install script
    • Restart again to start OneAgent on the host

Additional configuration optional

Use additional environment variables to configure OneAgent for troubleshooting or advanced networking. You can either set them via your App Service Application settings or, when using a custom container image, configure them within your application image Dockerfile.

Networking variables

ParameterDescription

DT_NETWORK_ZONE

Specifies to use a network zone. For more information, see network zones.

DT_PROXY

When using a proxy, use this environment variable to pass proxy credentials. For more information, see Set up OneAgent on containers for application-only monitoring.

Additional metadata for process grouping and service detection

Note: When listing multiple tags, you need to put them in double quotes, for example: DT_TAGS="Tag1=Value1 Tag2=Value2".

ParameterDescription

DT_LOCALTOVIRTUALHOSTNAME

Multiple containers are sometimes detected as a single instance (localhost), leading to various problems in, for example, service detection or availability alerts. Use this environment variable to define a unique name for your container instance. For details, see Service detection and naming

DT_APPLICATIONID

Some technologies don't provide unique application names. In such cases, use this environment variable to provide a unique name. For more information, see Web server naming issues.

DT_TAGS

Applies custom tags to your process group.

DT_CUSTOM_PROP

Applies custom metadata to your process group.

DT_CLUSTER_ID

If the process group detection rules won't work for your use case, use this environment variable to group all processes with the same value.

DT_NODE_ID

If the process group detection rules won't work for your use case, use this environment variable to separate process group instances.

Troubleshooting variables

ParameterDescription

DT_LOGSTREAM

Set this variable with stdout to configure the OneAgent to log errors to the console. To see additional OneAgent logs, set the log level with DT_LOGLEVELCON as follows.

DT_LOGLEVELCON

Use this environment variable to define the console log level. Valid options are: NONE, SEVERE, and INFO.

DT_AGENTACTIVE

Set to true or false to enable or disable OneAgent.

Update OneAgent

When an update is available, restart your application to update OneAgent.

Each time you want to leverage a new version of Dynatrace OneAgent, you need to 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

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

To uninstall OneAgent, remove references from above described Dynatrace integration from your application image and redeploy the application.

Troubleshooting

Potential conflict with Application Insights

OneAgent may conflict with Azure Application Insights agents already instrumenting the application. If you don't see any monitoring data coming in, check if you have turned on Application Insights and re-try with Application Insights turned off.

Related topics
  • Set up Dynatrace on Microsoft Azure

    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.