Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Newrelic agent for ASP.NET Core (1.1 and 2.0)


#1

Hi there,

Is it possible to configure somehow NewRelic .NET Agent (for .NET Framework) to work with ASP.NET Core applications (1.1 or 2.0)?
As I see in the documentation, .NET Core Agent can work with ASP.NET Core and Kestrel, but what is about .NET Framework Agent? I’ve tried to install .NET Framework Agent and just add configuration parameters to appsettings.json file but seems it doesn’t work.

Thank you in advance!


#2

Hi Pavel,

The .NET Core agent currently supports Core 2.0 only:

https://docs.newrelic.com/docs/agents/net-agent/getting-started/compatibility-requirements-net-core-20-agent#net-version

This is a separate installer and configuration from the .NET Framework agent as you can have both installed or just one or the other.

You can find a download link and install instructions for the Core agent here depending on your OS:

https://docs.newrelic.com/docs/agents/net-agent/installation/install-net-agent-windows

https://docs.newrelic.com/docs/agents/net-agent/installation/install-net-core-20-agent-linux


#3

beastman, thank you for your answer!

But seems my question was a bit confusing.

Look, there are two platforms to run .NET apps - .NET Framework (for Win apps only) and .NET Core (cross-platform). And yes, I understand that you have two separate agents for these platforms.

But there is an ASP.NET Core framework which can be used from .NET Framework or .NET Core platform. And for .NET Core agent I see that it supports ASP.NET Core framework.
But unfortunately we are using ASP.NET Core (and Kestrel as a web server) with .NET Framework 4.6.1 and have to use .NET Framework agent. And I don’t understand how to configure it properly for ASP.NET Core app.

Thank you for your help!

Best,
Pavel


#4

Are there any updates on this?


#5

Hey @pavelbelousov! I wanted to give you a quick update: we have our engineers looking into your question right now. In order to dig into your particular configuration with .NET Core, I am going to connect you via private ticket.

Hang tight and look out for my email. When you get all sorted, please be sure to come back and update the community via this thread! Thanks!


#6

Hi, similar situation here, running an aspnetcore app targeting 4.7.1 deployed to Azure.
I’ve managed to get NR recording data but the config is a little sketchy - I don’t seem to be able to use appsettings.json to set an appname, but I can use it to enable to profiler. Is there going to be any documentation created for this use case? The NR docs for netcore are a little shallow.

Your comment asking @pavelbelousov to come back to document his experience is a little unrealistic frankly.


#7

Hey @brett.lawrence, thanks for your community post!

You’re correct that the agent won’t pick up the name in appSettings.json at this time. I recommend either naming the application in the newrelic.config file or using the NEW_RELIC_APP_NAME key in your Azure app’s settings.

You may also need to specify the name of the targeted .NET Core process in your newrelic.config file.

For example, in this image captured from Kudu’s process explorer tab, here’s the name of my .NET Core process:

In this case, I’ll need to add the following to the newrelic.config file:

<instrumentation>
    <applications>
      <application name="coreframework.exe" />
    </applications>
</instrumentation>

Thanks for your feedback on our documentation. We’ll be looking into making the documentation for this particular application setup more clear.

Cheers,
Neil


#8

Hi Neil,

I have a similar situation as well. How would this work if you’re running multiple .Net core applications on the same server?

Is the current recommendation to install the .Net Core agent in “local” mode and create a dedicated newRelic.config file in the installation directory of the .net core agent? Similar to what is suggested in the following link(s) for the .net agent?

https://docs.newrelic.com/docs/agents/net-agent/installation/install-net-agent-using-scriptable-installer#installing-core
https://docs.newrelic.com/docs/agents/net-agent/configuration/name-your-net-application

Also, how do you setup the environment variables with multiple applications? It says to add the following environment vars for each app:

CORECLR_NEWRELIC_HOME=PATH_TO_INSTALL
CORECLR_PROFILER_PATH=%CORECLR_NEWRELIC_HOME%\NewRelic.Profiler.dll

But how can will this work? I cant have two instances of the same environment variable name with different values.

It would be great if we can specify the NewRelic.AppName config parameter in the appSettings.json file, similar to how its done in the web.config for IIS sites. Is there any ETA for adding the capability to the .Net core agent?

Thanks,
-Matt


#9

Hi @matt.bosch

Monitoring multiple .NET Core applications on the same server is fully supported.

There should never be a need to have multiple instances of the agent installed on the host, so the CORECLR_NEWRELIC_HOME, CORECLR_PROFILER_PATH and CORECLR_NEWRELIC_HOME variable values should be the same system-wide. You should only need one instance of those variables.

There are quite a few ways to configure the application name, so how you do it is a matter of what works best for you and how your application is structured.

What many people do is set the application name (or maybe even all of the environment variables) as an environment variable that gets loaded into the application process itself at runtime. This avoids the need to name the application in the newrelic.config file.

If you are using the AspNETCoreModule to configure IIS as a reverse proxy, you can also set the environment variables in the application’s web.config file.

You can even set environment variables directly in the command-line command you use to launch the application.

Basically, you’re looking for a way to get the environment variables you need into the application process itself, since that is ultimately what the agent will use. Each application you’re monitoring will have its own instance of the agent loaded into the process with it, and the variables that are present in the process are the ones that the agent sees. This is what we mean by setting the variables on an app-by-app basis.

We do have a feature request in place for loading the application name from the appsettings.json file and I’ll be happy to add your name to it.

For now, I think your best bet is to load the NEW_RELIC_APP_NAME environment variable directly into the application process.

Hope this helps,

Don


#10

Hi @matt.bosch,

On top of what Don said, I’ve found that setting the environment variables in each app’s launchSettings.json (usually in the Properties folder) is a good way to ensure that only specific apps will be monitored.

I have some example settings here. In addition to those settings, you can use NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME to set the license key and app name per app.

I hope that will work for your environment.

Thanks!
Neil


#11

Hi @dmorris and @ntierney,

Thank you for your suggestions. I’ve installed the .Net Core agent in local mode and setup the environment variables at the application level, however I don’t seem to be capturing any transaction data. For reference, this is the install command I ran:
.\installAgent.ps1 -Destination "c:\Program Files\New Relic\.Net Core Agent" -installType local -LicenseKey [INSERT HERE] -logDir "C:\ProgramData\New Relic\.NET Core Agent\logs"

I tried setting the environment variables in both the launchsettings.json file and in the web.config to no avail (performing an IISreset between all modifications). Here are the settings I configured in the web.config:

<aspNetCore processPath=".\AppName.exe" stdoutLogEnabled="true" stdoutLogFile="\\share\logpath" >
	<environmentVariables>
		<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
		<environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" />
		<environmentVariable name="CORECLR_PROFILER" value="{36032161-FFC0-4B61-B559-F6C5D41BAE5A}" />
		<environmentVariable name="CORECLR_NEWRELIC_HOME" value="C:\Program Files\New Relic\.Net Core Agent" />
		<environmentVariable name="CORECLR_PROFILER_PATH" value="C:\Program Files\New Relic\.Net Core Agent\NewRelic.Profiler.dll" />
		<environmentVariable name="NEW_RELIC_APP_NAME" value="AppName" />
	</environmentVariables>
<aspNetCore/>

I see the following in eventvwr when performing the IISreset, although I’m not sure if this is related to the .net core agent functionality
.NET Runtime version 2.0.50727.8762 - Failed to CoCreate profiler.
I followed the steps mentioned here, without any luck.

I do not see any of the New Relic dll’s attached to the w3wp process that is acting as the reverse proxy - although I’m not sure if I should expect to see them here or attached to the actual .net core application itself.

I’m not seeing any logs generated in the log path specified. I also made sure that the user running the process has R/W access to the install and log directories, as suggested by @ntierney.

Do either of you have any other suggestions?


#12

Hi @matt.bosch,

I noticed a typo that can be preventing the environment variables from loading into the process. The last line of your code should be:

</aspNetCore>

Other than that, the XML looks good.

What is the targeted framework of your app? If you take a look at your .csproj file, what is set as the target framework:

<TargetFramework>netcoreapp2.0</TargetFramework>

I just want to confirm this is a Core app targeting Core rather than .NET Framework.

Thanks,
Neil


#13

Hi @ntierney,

Yes there was indeed a typo in the xml, thanks for spotting that! Additionally, you were correct in assuming that this app was targeting the .net framework rather than core, which was required due to some of the dependencies still using .net. The post you linked to definitely helped.

I’m now successfully capturing data from both .NetCore apps on the same system (one targeting .net framework and the other being a native .net core app).

Its great that you’ve been able to help me get this setup, however I’d recommend adding some of these key bits of information into the documentation itself.

Thanks again for your help!
-Matt


#14

Any plans on the roadmap for the upcoming .NET Core 2.1? I’ve been using the RC1 version and it would be really sweet to keep supporting New Relic on our middleware.


#15

@sam.sarmento - thanks for reaching out. We haven’t had a chance to get to this yet but hope to in the second half of the year.


#16

As a side note to the folks that are following this topic, we recently added support for instrumenting ASP.NET core applications targeting .NET framework: https://docs.newrelic.com/docs/release-notes/agent-release-notes/net-release-notes/net-agent-817120


#17

Microsoft also added support for Alpine Linux in .NET Core 2.1, so it’d be great if the New Relic agent did too.


#18

Hi, Any idea when support for 2.1 will come out. We are ready to upgrade, but it is a no-go until the Newrelic agent supports it…


#19

Same here, .NET Core 2.1 is an important milestone, and we get Bad IL format due to NewRelic agent.


#20

Regarding support for .NET Core 2.1, I wanted to share this post from a similar thread:

Thanks!

Neil