APM .NET Agent Public API Configuration

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.

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

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.

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

Given the server URL can be configured for ASP.NET Core using IConfiguration (by setting ElasticApm.ServerUrls in a settings JSON file), can a similar configuration not also be done for ASP.NET Full Framework so that ELASTIC_APM_SERVER_URLS doesn't need to be set? I can't see in Elastic.Apm.AspNetFullFramework if it's possible.

Do you mean setting ElasticApm.ServerUrls somewhere in web.config or something else?

In any case you are welcome to open an enhancement issue at the Github repo.

Yes, exactly. I've added an issue for this.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.