APM .NET Agent Public API Configuration

dotnet
#1

How do we specify the ServerUrls, ServiceName, etc. when using the Public API of the APM .NET Agent? I need to change from the default http://localhost:8200 to a different URL but I am unable to find where it needs to be set.

The application I am trying to instrument manually is a web application on .NET Framework 4.5. I have a few console applications on .NET Framework 4+ that I am planning to do as well if I can figure out how to set the configurations properly.

(gonindzya) #2

hi @kburge
https://www.elastic.co/guide/en/apm/agent/dotnet/current/config-reporter.html

(Greg Kalapos) #3

Hi @kburge,

thanks @nugusbayevkk for the link, that's exactly the part of the documentation that contains the answer.

So the default way to configure the agent is to use environment variables, that works with basically every setup (then we also have IConfiguration for ASP.NET Core, but that's not the topic here...). For changing the URL of the server the ELASTIC_APM_SERVER_URLS environment variable should be used.

#4

Awesome! Thank you.

I wasn't sure about how the environment variables work in C# so for anyone else that comes across this you just do this at the beginning of your code:

Environment.SetEnvironmentVariable("ELASTIC_APM_SERVER_URLS", "http://your-apm-server:8200");
Environment.SetEnvironmentVariable("ELASTIC_APM_SERVICE_NAME", "Your Service Name");

1 Like