How do I monitor OpenShift applications only?

This page describes how you can monitor application workloads running on OpenShift Online where you don't have access or permissions to deploy OneAgent to the OpenShift cluster. If you have access to your OpenShift cluster like for OpenShift Container Platform, please visit How do I deploy Dynatrace OneAgent on OpenShift Container Platform?

What you need:

  • Dynatrace environment credentials

Also, be sure to review the list of supported applications and versions.

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.

The code snippet below shows the parts you'll need to add to your application images. First, define variables with optional default values using ARG instructions. Please note, you can override the default values within the OpenShift BuildConfig. 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.

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

To integrate OneAgent and activate instrumentation of your application, add the following commands to your current Dockerfile.

ARG DT_API_URL="https://<environmentID>"
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/" "$DT_API_URL/v1/deployment/installer/agent/unix/paas/latest?Api-Token=$DT_API_TOKEN&$DT_ONEAGENT_OPTIONS" && \
    unzip -d "$DT_HOME" "$DT_HOME/" && \
    rm "$DT_HOME/"
ENTRYPOINT [ "/opt/dynatrace/oneagent/" ]
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

In an OpenShift context the above Dockerfile could be used for binary builds in the following way:

$ oc new-build --binary --strategy=docker --allow-missing-images yourapp
$ oc patch bc/yourapp --type=json --patch='[{"op":"remove","path":"/spec/strategy/dockerStrategy/from"}]'
$ oc start-build yourapp --from-dir=. --follow

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

Update OneAgent for OpenShift

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

The process described here respects the defined settings you've applied in the OneAgent updates settings page.