Monday 15 July 2019

How to monitor DotNetCore App in ElasticSearch using APM?

Steps:
  1. Download & Install ElasticSearch
  2. Download and Install Kibana
  3. Download and install Apm-Server
  4. Add Apm-Agent in to DotnetCore App
  5. Monitor your app in Kibana under Apm Tab.

1. Download & Install ElasticSearch

Download latest ElasticSearch MSI from here
https://www.elastic.co/downloads/elasticsearch
Install it with default settings and verify service up on http://localhost:9200/


2. Download and Install Kibana

Download latest Kibana Zip from https://www.elastic.co/downloads/kibana
Extract Zip by using 7zip if you facing any issue while extracting, in folder C:\Program Files\ElasticSearch\
Run Kibana as service:

Open CMD as administrator
sc create "ElasticSearch Kibana 7.2.0" binPath= "C:\Program Files\ElasticSearch\kibana-7.2.0-windows-x86_64\bin\kibana.bat" depend= "Elasticsearch" start= auto

Verify service up on http://localhost:5601/



Remove Kibana from service():
Open CMD as administrator
sc Delete "ElasticSearch Kibana 7.2.0"


3. Download and install Apm-Server

Now in Kibana go to APM http://localhost:5601/app/apm#/services?_g=()
Follow Windows setup instructions:
Download APM from https://www.elastic.co/downloads/apm

Follow install instruction by using Powershell.

Verify service up on http://localhost:8200/


4. Add Apm-Agent into DotnetCore App

Now follow application setup instruction:
For Dotnet core install following Nuget package with a pre-release check as per your requirement
• Elastic.Apm
• Elastic.Apm.All
• Elastic.Apm.AspNetCore
• Elastic.Apm.EntityFrameworkCore

And Add middleware UseElasticApm in starup.cs

public class Startup
{
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
    app.UseElasticApm(Configuration);
    //…rest of the method
  }
  //…rest of the class
}


5. Monitor your app in Kibana under Apm Tab.

And verify tracing under APM