How to setup Opbeans-dotnet for Elastic APM

Hi there,

I'm running ELK 7.7 with APM 7.7.

I have successfully setup Opbeans-java for APM monitoring.

I have also downloaded and run the Opbeans-dotnet application.

How do i setup APM .net agent for it?

I have run the following:

Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.208 -Force
Get-PackageSource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
nuget.org                        NuGet            False      https://api.nuget.org/v3/index.json
PSGallery                        PowerShellGet    False      https://www.powershellgallery.com/api/v2

Set-PackageSource nuget.org -Trusted

Install-Package Elastic.Apm.AspNetCore -Version 1.6.1

Install-Package : A parameter cannot be found that matches parameter name 'Version'.
At line:1 char:40
+ Install-Package Elastic.Apm.AspNetCore -Version 1.6.1
+                                        ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Install-Package], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Install-Package Elastic.Apm.AspNetCore
Install-Package : No match was found for the specified search criteria and package name 'Elastic.Apm.AspNetCore'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Elastic.Apm.AspNetCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 -ProviderName NuGet
Install-Package : No match was found for the specified search criteria and package name 'Elastic.Apm.NetCoreAll'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

How do I install the Elastic.Apm.AspNetCore package?

Thanks,
ck

Hi @ckough,

just follow the docs - Opbeans-dotnet is an ASP.NET Core application, so turning on the agent is the same for it as turning it on to any other ASP.NET Core app.

I suspect this is the missing part:

using Elastic.Apm.NetCoreAll;

public class Startup
{
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
    app.UseAllElasticApm(Configuration); //<- add this line, this activates the agent
    //…rest of the method
  }
  //…rest of the class
}

Alternatively you can also try our brand new no code change approach, which is currently in Beta:

Documentation is here in the readme file: https://github.com/elastic/apm-agent-dotnet/tree/master/src/ElasticApmStartupHook#how-to-use-it

Hi Greg,

Thanks for the reply.

My question is not so much on how to configure the agent as how to install it.

My issue is i can't seem to do the install-package command bc the package is not found.

I've used:
Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 -ProviderName NuGet
Install-Package Elastic.Apm.AspNetCore
Install-Package Elastic.Apm.AspNetCore -Version 1.6.1

and the latter 2 tells me:
No match was found for the specified search criteria and package name 'Elastic.Apm.AspNetCore'

So the question is still how do I set up the Elastic.Apm.AspNetCore package in Windows?

Thanks,
ck

The packages are NuGet packages, so all you need to do is to install the NuGet packages to the app.

Except if you go with the beta release I linked where you can attach the agent during startup as that doc states:

Agent assemblies need to be loaded onto the disk where the traced .NET app is running. The agent with all the necessary files is currently distributed via GitHub on the releases page through a zip file (ElasticApmAgent_[version].zip).

So in that case you'd download the .zip file, unpack, and then set the environment variable as the doc states.

But you are already trying to install the NuGet pacakge, so let's stick to that.

Typically people install NuGet packages directly in Visual Studio (Right click on the project you want to add the agent to -> click on Manage NuGet Pacakges -> A new windows pops up -> Click on the browse tab -> enter the Elastic.Apm.* -> select and click install).

Other way to do this is to use the dotnet command - once you install the .NET CLI, you can execute

dotnet add package Elastic.Apm.AspNetCore --version 1.6.1

Alternatively you can also pull nuget.exe from here and execute:

nuget.exe install Elastic.Apm.AspNetCore -Version 1.6.1 -PreRelease

This is a good overview from Microsoft on all the ways people can use to install NuGet packages.

Now to the command you pasted (Sorry I did not look at those enough when I wrote my 1. response).

Do you run those commands in a plain PowerShell command outside Visual Studio? To be honest I never installed NuGet pacakges from PowerShell directly. Those commands should typically run in the Visual Studio (Tools -> Package Manager -> Package Manager console).

I tested and it works for me

This is also a PowerShell command line, but with a different profile. There is also a note about this here

I managed to make it work with PowerShell, I had the same issue as you originally, but then this StackOverflow entry helped me - setting it to the old v2 API made it work. But I think none or only very few of our users do this - I'd suggest not doing it.

I'd suggest to just pulling the dotnet CLI or nuget.exe and install the package with those if you want command line, or use Visual Studio or any other IDE that supports NuGet.

Also one comment to this part:

I've used:
Install-Package -Name Elastic.Apm.NetCoreAll -RequiredVersion 1.6.1 -ProviderName NuGet
Install-Package Elastic.Apm.AspNetCore
Install-Package Elastic.Apm.AspNetCore -Version 1.6.1
and the latter 2 tells me: ...

One you installed Elastic.Apm.NetCoreAll you are good to go, that package contains Elastic.Apm.AspNetCore, so if you use the NetCoreAll package, there is no need to reference other agent packages (more on this in our docs).

Also keep in mind that the code change I pasted above is needed to complete the agent setup, unless you go with the startup attachment beta feature.

I hope this helps.

Hi Greg

Your suggestions work perfectly. Thank you for all the help!

1 Like

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