cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

A new way to install .NET Agent into Docker containers

Alex.Fedotyev
AppDynamics Team (Retired)

Table of Contents

Overview
Dockerfile snippet
How to use the Dockerfile
Special instructions for Alpine users

 

Overview

AppDynamics .NET Agent for Linux supports monitoring .NET Core 2.x and 3.0 applications, and it is becoming more and more popular with customers who use containers to run their applications.

There are several ways to deploy the agent after you download it from https://download.appdynamics.com/. You can include agent files in the Docker file, load them from a sidecar container or share them on a separate volume.

Even though there’s this flexibility of use, we’ve been looking at options to simplify the agent deployment and configuration!

The idea that drove this effort is simple:

  1. Simplify agent download, installation and configuration altogether using Dockerfile features like multi-state builds (https://docs.docker.com/develop/develop-images/multistage-build/)
  2. Obtain agent from the portal using new download API (https://docs.appdynamics.com/display/LATEST/Download+AppDynamics+Software)
  3. Prepare agent binaries and copy them to target container
  4. Configure all required agent properties based on documentation (https://docs.appdynamics.com/display/LATEST/Install+the+.NET+Agent+for+Linux)

 

Dockerfile snippet

Here is the snippet of a Dockerfile that does all that!

# Download AppDynamics agent during multi-stage docker build
# Insert this portion at the top of your Dockerfile
FROM mcr.microsoft.com/powershell as APPDTOOL
WORKDIR /agent
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# !!!Important: Replace user name and password with proper identify at accounts.appdynamics.com
RUN $user = "<user name for AppDynamics account>"; \
    $pwd = "<password for AppDynamics account>"; \
    $request = [string]::Format("{{""username"": ""{0}"",""password"": ""{1}"",""scopes"": [""download""]}}", $user, $pwd); \
    $token = Invoke-WebRequest -Method POST -Body $request -Uri https://identity.msrv.saas.appdynamics.com/v2.0/oauth/token | ConvertFrom-Json; \
    $agents = Invoke-WebRequest -Uri https://download.appdynamics.com/download/downloadfilelatest/ | ConvertFrom-Json; \
    $agent = $agents | where { $_.filetype -eq "dotnet-core" -and $_.os -eq "linux"  }; \
    Invoke-WebRequest -Authentication Bearer -Token (ConvertTo-SecureString -AsPlainText -Force $token.access_token) -Uri $agent.download_path -OutFile agent.zip; \
    Expand-Archive ./agent.zip ./files
 
 
 
# Your existing Dockerfile logic needs to be put in here
# ==== BEGIN ===

# ===== END ====
 
 
# Insert this line at the end of your existing Dockerfile to copy agent files to an application container
COPY --from=APPDTOOL /agent/files /opt/appdynamics/dotnet
# Mandatory settings required to enable the agent for .NET Core application
ENV CORECLR_PROFILER={57e1aa68-2229-41aa-9931-a6e93bbc64d8} \
    CORECLR_ENABLE_PROFILING=1 \
    CORECLR_PROFILER_PATH=/opt/appdynamics/dotnet/libappdprofiler.so

 
# Configure connection to the AppDynamics controller
ENV APPDYNAMICS_CONTROLLER_HOST_NAME=controller.saas.appdynamics.com
ENV APPDYNAMICS_CONTROLLER_PORT=443
ENV APPDYNAMICS_CONTROLLER_SSL_ENABLED=true
ENV APPDYNAMICS_AGENT_ACCOUNT_NAME=account-name
ENV APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY="access-key"
 
# Configure application identity in AppDynamics
ENV APPDYNAMICS_AGENT_APPLICATION_NAME="My Application"
ENV APPDYNAMICS_AGENT_TIER_NAME="Sample Tier"
ENV APPDYNAMICS_AGENT_REUSE_NODE_NAME=true
ENV APPDYNAMICS_AGENT_REUSE_NODE_NAME_PREFIX="Instance"

 

How to use the Dockerfile snippet

  1. Dockerfile contains two parts: check the comments to see how to properly insert those into your existing Docker file.
  2. On top of the Dockerfile: insert correct credentials for the account that will be used to pull down the agent from the download portal (this an account at www.appdynamics.com, not the SaaS controller user name). You can also create a custom user that will be used just for download purposes.
  3. At the bottom of the Dockerfile: make sure to include the SaaS controller details and application and tier names.

 

Special instructions for Alpine users

  • To get the correct Agent binaries, you will need to update OS match condition to new value "alpine-linux" In the script to get correct agent binaries.
  • Specify library path on Alpine containers by adding one more line to the bottom: ENV LD_LIBRARY_PATH=/opt/appdynamics/dotnet

This is the first version of this Dockerfile — I’m looking to mature it over time.

So, please, share your feedback, suggestions, and issues with me!

Regards,

-Alex

5 REPLIES 5

Ryan.Paredez
Community Manager

Hello AppD Community,

 

We are still looking for feedback. If you have any, please do reply to this post with your experience. Provide as much detail and context as you can.

 

Thanks for your time and contributions. 


Thanks,

Ryan, Cisco AppDynamics Community Manager




Found something helpful? Click the Accept as Solution button to help others find answers faster.

Liked something? Click the Thumbs Up button.



Check out Observabiity in Action

new deep dive videos weekly in the Knowledge Base.

Jesse.Prescott
New Poster

Thank you for this, it got me started. I do get the following error:

appd.agent.profiler(Info): Not able to find config from path /opt/appdynamics/dotnet/AppDynamicsConfig.json

So I'm guessing I have to create a config file

Claudia.Landivar
Community Manager

Hi, @Jesse.Prescott – Did you have any luck after creating the config file?



Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.

Well I don't get that error anymore. Looking at the logs, I don't see any errors. But also not seeing any data in my AppD dashboard, so it doesn't appear to be working. But it could just be my configuration. I'm new to all of this.

Ryan.Paredez
Community Manager

Hi @Jesse.Prescott,

At this point, I would recommend contacting Support at this time for more help. How do I submit a Support ticket? An FAQ 


Thanks,

Ryan, Cisco AppDynamics Community Manager




Found something helpful? Click the Accept as Solution button to help others find answers faster.

Liked something? Click the Thumbs Up button.



Check out Observabiity in Action

new deep dive videos weekly in the Knowledge Base.