Elastic APM with ASP.Net and IIS server configuration

Hi,

I want to instrument asp.net MVC application with Elastic APM agent and got through this link Configuration on ASP.NET | APM .NET Agent Reference [1.12] | Elastic which requires to add the configuration in the web.config file of the application.
Is there a way to configure the application without making changes in the application, Like the way we have it in the aspnet core applications with zero code changes method of configuration.

Secondly, I want to configure my aspnetcore application by deploying it in IIS server. Until now I have tried configuring the elastic apm agent with standalone executables using zero code changes method of configuration

Is the agent configurable with the IIS server as well? Do i need to have additional configurations in case of applications on IIS -(aspnetcore and asp.net any of them).

Thanks in advance,
Namita

Is there a way to configure the application without making changes in the application, Like the way we have it in the aspnet core applications with zero code changes method of configuration.

Yes, there is. We have a profiler based agent in beta current which covers your use case. You can see the docs here: Profiler Auto instrumentation | APM .NET Agent Reference [1.12] | Elastic

Regarding you question about configs: the agent will by default read configs through environment variables - the environment variables for each config can be found in the docs. So that should work - have you tried that?

Hi @GregKalapos ,

Thankyou for providing me with the link for reference.

I have tried setting up the configuration for my netcore application. However , The application service is not visible in kibana.

I have followed below steps:

Downloaded and unizpped the beta version of the profiler.
Tried setting the environment variable through appcmd.exe via powershell
Below is the screenshot of the same:

Performed IIS stop and start
net stop /y was
net start w3svc

Reloaded the application and performed few transactions. After performing few transactions as well , the service is not visible in kibana.

Could you please advise on the same. Please do let me know if at all I have missed out on any of the steps required.

Thankyou in advance,
Namita

Oh, sorry, I maybe misunderstood.

So, here is what setups we currently offer:

Now, very important: the profiler currently does not support ASP.NET Core running on netcoreapp (or well, it does, but there is a missing feature to automatically start the transaction - we want to cover this later, actually I'm working on this now..) - regardless of where the application runs.

So, from what you write it seems you have an ASP.NET Core application on top of netcoreapp which you run in IIS. Is that correct? If that's the case then the zero code change setup with the startuphook method should work (and not the profiler at this point): .NET Core | APM .NET Agent Reference [1.12] | Elastic.

If that does not work, then we'll need to see what's going on, but probably that'd be the right way to go. Can you maybe collect logs from that setup? There is also a short troubleshooting section here which tells you how to collect logs form the loader: apm-agent-dotnet/src/ElasticApmAgentStartupHook at main · elastic/apm-agent-dotnet · GitHub - just do set ELASTIC_APM_STARTUP_HOOKS_LOGGING=1 - could you please give this a try and see if there is something relevant in those logs?

@GregKalapos

Thanks a lot for providing such detailed information. :+1:
Yes, I was trying to configure ASP.net Core application on IIS. I have tried out with zero code changes that uses startuphook method and its working fine.

Hence moved further checking with IIS.

Also, The link provided for asp.net on can be done in 2 ways
by adding elasticapm in web.config OR
by adding ELASTIC_APM_FULL_FRAMEWORK_CONFIGURATION_READER_TYPE in environment variable.

Any one of the above will do or I'll have to configure both in web.config as well as environment variables.
Please correct my understanding on above.

Thanks in advance,
Namita

Oh - if you have a setup with the startuphook method which works for your ASP.NET Core app on top of netcoreapp, then you don't need the IIS module.

I see how this can be confusing... but Microsoft created so many .NET versions over the last decades :slight_smile:

So, even if your ASP.NET Core app runs in IIS, the way to turn on the agent will be the one described in the zero code change setup: .NET Core | APM .NET Agent Reference [1.12] | Elastic

In that case you can just ignore the IIS related docs we have - you won't really get anything more out of the app by adding it. That doc is specifically for ASP.NET Classic on .NET Full Framework which can only be deployed in IIS - so that's the tech stack which pre-dates ASP.NET Core.

You can run ASP.NET Core apps on IIS as well, but for that setup you won't need our IIS module.

So, what's exactly your goal? If it already works with startuphook, then it should work in IIS and that'd be the preferred way to enable the agent with zero code change for ASP.NET Core in that setup.

Or do I misunderstand something and something does not work for you?

1 Like

I had tried the startuphook method by declaring the environment variables required in a shell and then triggered it along with the standalone netcoreapp executable.

Today , I declared them in my system's environment variables and deployed the executable in the IIS. That did work :slightly_smiling_face:
I am able to get the traces now.

Thanks alot! :+1:

Best Regards,
Namita

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