Monitor AWS Fargate
To deploy OneAgent on AWS Fargate, read the instructions provided below.
Prerequisites
- Create an API token in your Dynatrace environment and enable the following permissions:
- Access problem and event feed, metrics, and topology (API v1)
- PaaS integration - Installer download
- Review the list of supported applications and versions.
Integrate OneAgent into your application image
There are three ways to integrate OneAgent with AWS Fargate applications.
Automatic injection
Automatic injection(For EKS only) manages upgrades and lifecycle.
Kubernetes version 1.20+
On AWS Fargate, only the applicationMonitoring
deployment without the CSI driver is supported.
Before you start installation, make sure you have a running AWS Fargate cluster. For details, see Getting started with AWS Fargate using Amazon EKS.
-
Add a Fargate profile to define the Dynatrace Operator deployment.
Be sure it matches the
dynatrace
namespace where Dynatrace Operator will be deployed. -
Create a
dynatrace
namespace.1kubectl create namespace dynatrace -
Install Dynatrace Operator.
1kubectl apply -f https://github.com/Dynatrace/dynatrace-operator/releases/download/v0.14.0/kubernetes.yaml -
Create the secret holding the API token for authentication to the Dynatrace cluster.
Be sure to replace
<API_TOKEN>
with your own value.1kubectl -n dynatrace create secret generic dynakube --from-literal="apiToken=<API_TOKEN>" -
Download the preconfigured DynaKube custom resource sample file from GitHub.
-
Review the available parameters, and adapt the DynaKube custom resource according to your requirements.
-
Apply the DynaKube custom resource.
1kubectl apply -f applicationMonitoring.yaml
Build-time injection
Build-time injection (for ECS, EKS) embeds OneAgent into your container image.
To use this option you need:
Docker version 17.05+.
OneAgent version 1.155+.
-
Sign in to Docker with your Dynatrace environment ID as username and PaaS token as password.
1docker login -u <your-environment-id> <your-environment-url> -
Add two additional lines of code to the application image, after the last
FROM
command:1COPY --from=<your-environment-url>/linux/oneagent-codemodules:<technology> / /2ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so- Replace
<your-environment-url>
with the URL or IP address of your environment or of your ActiveGate. - Replace
<technology>
with the code module required for your application. Valid options areall
,java
,apache
,nginx
,nodejs
,dotnet
,php
,sdk
, andgo
. You can specify several code modules, separated by hyphen (-
), for examplejava-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:
1COPY --from=<your-activegate>/linux/oneagent-codemodules-musl:<technology> / /2ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.soValid options here are
all
,go
,java
,apache
,nginx
, andnodejs
. - Replace
-
Build your application image.
Build the Docker image from your dockerfile to use it in your Kubernetes environment:
1docker build -t yourapp .You can monitor your application containers with a different Dynatrace environment. To do this, read the instructions below:
For OneAgent version 1.139+, if you have an existing application image where you've 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. Make sure to adapt the respective placeholders
<your-environment-id>
and<your-paas-token>
.1curl "https://<your-environment-id>.live.dynatrace.com/api/v1/deployment/installer/agent/connectioninfo?Api-Token=<your-paas-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
: equalstenantUUID
DT_TENANTTOKEN
: equalstenantToken
DT_CONNECTION_POINT
: semi-colon separated list ofcommunicationEndpoints
Runtime injection
Runtime injection (for ECS only) pulls OneAgent when the container starts.
To install Dynatrace OneAgent at runtime, you must deploy your application using a task with two container definitions. One is for downloading and unzipping the OneAgent to a shared volume, the other is your application container, which must mount the same volume.
For the runtime injection, follow the steps below.
-
Go to Fargate Task Definition > Create New Task Definition > select Fargate > click Next Step.
-
Name the task, optionally set roles and sizes, then scroll down to Volumes > Add volume. Add a volume of type
Bind Mount
namedoneagent
.You must create a volume before creating container definitions in order to set the shared volume in each container.
-
Scroll up to Container Definition > choose Add container, and in the Standard subsection, add a container named
install-oneagent
, set the image to Alpine versions 3.8+ ("alpine:3"), and select the memory limits.There are two types of memory limits: soft and hard. ECS requires that you define the limit for at least one type of memory. We recommend using the default setting (soft limit of 128 MiBs), as it's less restrictive, but you can adjust it as needed.
-
Scroll to Environment and do the following:
-
Uncheck the Essential parameter.
-
In the Entry point field, enter
/bin/sh,-c
. -
In the Command field, enter
ARCHIVE=$(mktemp) && wget -O $ARCHIVE "$DT_API_URL/v1/deployment/installer/agent/unix/paas/latest?Api-Token=$DT_PAAS_TOKEN&$DT_ONEAGENT_OPTIONS" && unzip -o -d /opt/dynatrace/oneagent $ARCHIVE && rm -f $ARCHIVE
.
-
-
In the Environment variables subsection, define:
-
DT_API_URL
- this is the API URL for your Dynatrace environment.- For SaaS:
https://<your-environment-id>.live.dynatrace.com/api
- For Managed:
https://<cluster>/e/<your-environment-id>/api
- For ActiveGate:
https://<your-active-gate-IP-or-hostname>:9999/e/<your-environment-id>/api
.
- For SaaS:
-
DT_ONEAGENT_OPTIONS
- this is the flavor (valid options aredefault
ormusl
for Alpine images) and the technology (code module).- Syntax for
default
isflavor=default&include=all
. - Syntax for
musl
isflavor=musl&include=all
.
- Syntax for
-
DT_PAAS_TOKEN
- this is your PaaS token to download the OneAgent code modules.
-
-
Scroll to Storage and logging to define the mount point with the source volume
oneagent
and the container path/opt/dynatrace/oneagent
. -
Click Add to create the container definition.
-
Choose Add container again, this time to define your application, and complete the fields in the Standard subsection according to your application requirements.
-
Scroll to Environment, and in Environment variable, define
LD_PRELOAD
with the value/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
. -
Scroll to Startup Dependency Ordering and enter the container name
install-oneagent
and the conditionComplete
. -
Scroll to Storage and logging to define the mount point with the source volume
oneagent
and the container path/opt/dynatrace/oneagent
. -
Select Update to update your container definition.
-
Deploy the new version of your task definition on your ECS cluster.
- On the Logs tab for the
install-oneagent
container, you can see the code modules' ZIP file being downloaded by wget and being unzipped. - On the Logs tab for your application workload container, you can see the code module being loaded by the process.
In the Dynatrace web UI, your Fargate application workload container will show up in the Hosts section. The instrumented process will show up in Processes as a typical Docker container.
The runtime approach requires Fargate versions 1.3+. For earlier versions, select the build-time approach.
Troubleshoot OneAgent integration issues
If you encounter issues integrating OneAgent, use one of the troubleshooting variables, DT_LOGLEVELCON
= INFO
. It will enable you to see OneAgent logs on the CloudWatch logs.
-
Automatic injection
Make sure theDT_LOGLEVELCON
environmental variable is defined and set toINFO
on the container where OneAgent runs. -
Build-time injection
Enter an additional line of code to the application image as in the example below:1COPY --from=<your-environment-url>/linux/oneagent-codemodules:<technology> / /2ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so3ENV DT_LOGLEVELCON INFO -
Runtime injection
In the point 9, scroll to Environment, and in Environment variable, defineDT_LOGLEVELCON
with the valueINFO
.
Configure network zones optional
You can configure network zones as an environment variable:
DT_NETWORK_ZONE
: equalsyour.network.zone
See network zones for more information.
Monitoring consumption
For AWS Fargate, monitoring consumption is based on host units. To learn how host units are calculated for Dynatrace application and infrastructure monitoring, see Application and Infrastructure Monitoring (Host Units).