[.NET] APM Dockerfile - OpenShift

Hello,
I need to place a .NET application to use APM New Relic, it is running on docker, the installation is successful, but the data is not shown.

Note: The application is using openshift

Below is the Dockerfile I am using:
FROM nexus-gab.aguiabranca.com.br:5000/mcr.microsoft.com/dotnet/core/aspnet:5.0

ARG DIR_TO_COPY
ARG DDL_MAIN
ENV DLL_MAIN_ENV ${DDL_MAIN}
ENV TZ=America/Sao_Paulo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
&& apt-get update && apt-get install -y wget ca-certificates gnupg
&& echo ‘deb http://apt.newrelic.com/debian/ newrelic non-free’ | tee /etc/apt/sources.list.d/newrelic.list
&& wget https://download.newrelic.com/548C16BF.gpg
&& apt-key add 548C16BF.gpg
&& apt-get update
&& apt-get install -y newrelic-netcore20-agent
&& rm -rf /var/lib/apt/lists/*
&& -d --name newrelic-infra --network=host --cap-add=SYS_PTRACE --privileged --pid=host -v “/:/host:ro” -v “/var/run/docker.sock:/var/run/docker.sock”
&& -e NRIA_LICENSE_KEY=66ca95e9bxxxxxxxxxx newrelic/infrastructure:latest

ENV CORECLR_ENABLE_PROFILING=1
NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
CORECLR_NEWRELIC_HOME=/usr/local/newrelic-netcore20-agent
CORECLR_PROFILER_PATH=/usr/local/newrelic-netcore20-agent/libNewRelicProfiler.so
NEW_RELIC_LICENSE_KEY=66cxxxxxxxxx
NEW_RELIC_APP_NAME=app

WORKDIR /app
COPY $DIR_TO_COPY .
ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
ENTRYPOINT [“dotnet”, “app.dll”]
CMD dotnet ${DLL_MAIN_ENV}

Hello @equipeinfra.gab. Welcome to the Explorers Hub.

I wanted to reach out and see if you are still unable to see your data in New Relic. If you are still experiencing this issue, would you kindly provide a link to your application in the New Relic UI?

Thank you.

Hi Michael,

I’m still having issues to view my data on NewRelic. My application is on my private network and can’t be accessed externally. I don’t get any erros on application (he works normally), but I don’t receive any agent logs in the pod neither data on portal. In the pod I can see dotnet logs normally.

Is there any environment variables that I have to use in non root containers (default for RedHat OpenShift)?

Thank you, @equipeinfra.gab, for reaching out and letting me know you are experiencing this still. I am sorry you are having troubles. As I am a moderator, .NET is out of my scope, so please allow me to loop in one of our support engineers to assist further. They will respond here shortly, when available.

Do reach out with any other questions you may have as well, we will be happy to answer them.

Hello @equipeinfra.gab

Thanks for all of that detailed information.

I will note that the default install location has changed for our latest agents (to newrelic-dotnet-agent) and you may need to update your Dockerfile to look more like this example:

Other thoughts:

  • The agent files and environment variables must be in place before your application runs and your application process must have the environment variables loaded, which you can verify with:
xargs --null --max-args=1 < /proc/[pid]/environ | grep "CORECLR_"

Replace pid with the actual pid of your running process.

In the container, do you get any results with the command:

sudo cat /proc/[pid]/maps | grep "libNewRelicProfiler.so"

Replace pid with the actual pid of your running process.

  • If you are managing your Linux services with systemd or supervisord you need to add the required environment variables to the relevant process sections of those daemons’ configuration files as described in their documentation.

  • You could try setting the environment variable NEWRELIC_LOG_DIRECTORY to a location that has “everyone” permissions to see if the agent can log there.

  • You mentioned that there are profiler and/or agent logs — do you see anything in those logs that could indicate a problem?

  • You mentioned a private network so I wanted to confirm that you opened the required IPs, ports, and endpoints as described here:

https://docs.newrelic.com/docs/new-relic-solutions/get-started/networks/#agents

I hope this helps!