Application Insights In MVC Core, Web API Core And Entity Framework Core

Introduction

In this article, we learn about Application Insights SDK setup in a local environment using Visual Studio 2019 community edition. It helped to diagnose issues by using Application Insight SDK in Visual Studio 2019. By using this SDK, we can get collection-level information using application insights telemetry such as request rates, response times and failure rates, exceptions, etc.

Prerequisites

  1. Visual Studio 2019 - Community Edition
  2. Azure SDK

Learning Series

  1. Part 1
  2. Part 2
  3. Part 3
  4. Part 4

Step 1. Right-click on your application and select the ‘Configure Application Insights’ option, as shown in the below screenshot.

Configure application insights

Step 2. Select the first option, Application Insights SDK (Local), and click on the ‘Next’ button, as shown in the below screenshot.

Application insight sdk(local)

Step 3. In the below screenshot, your Application Insights information will be fetched based on your subscription which is mapped with your email ID using Visual Studio 2019. Select your valid Application Insights App service name and click on ‘Next’ for the next process.

If your Visual Studio is not retrieving your Azure subscription or app services, you need to re-login with your valid login details which are mapped with your Azure subscription service so that it retrieves all your subscriptions and application insights services using Visual Studio 2019.

Azure for student

Step 4. Now it’s re-validate the application insights connection string and click on ‘Next’ for the project dependencies section.

Instrument key name

Step 5. Select all checkboxes as shown in the below screenshot and click on the ‘Finish’ button.

Azure application insights

Step 6. The configuration process was done and is shown in the below screenshot.

Click on close

Step 7. Now select the ‘View’ option - > go ‘Other Windows’ -> select the Application Insights Search option as shown in the below screenshot.

Application insights search

Step 8. The basic Application Insights dashboard was opened and options were available for basic local environments like in the below screenshot.

  1. Application Insights Dashboard tab.
  2. Search option for all types of collection-level logs.
  3. Application Insights Information details.
  4. Time ranges for all collections – Filters for basic visual analytics.
  5. All types of Collections.
    All types of collection

Step 9. Select a custom range and provide from and to dates to retrieve collection-level traces.

In this section, you’ll get all collection level logs, statistics graphs, more filters which is available in Refine By Section, etc.

  1. Collection Level details are separated by count level.
  2. Statistics graph available for selected time ranges, collection level, etc.
  3. Results in the selected range of information would be very helpful for logging.
  4. Refine Section will help to filter the sections like Requests, Dependencies, and request URLs.
  5. Stack information will be listed in detail along with execution time, request type, request URL, device type, collection type information, etc.Results

Step 10. The diagnostic tool will provide Process Memory, Events, and CPU % for all collections.

  1. In Application Insights logging, operation ID will play a major role in filtering, getting logs, collections involved in selected operation ID, etc. This type of information very much helps the developer to debug more into the application.
  2. In the below screenshot, the statistics graph for the request collection level for a selected particular ID.
  3. Stack information in detail.
  4. Refine section.
  5. Search new data with the selected operation ID.
    Operation id

Step 11. If there are multiple application that needs to be monitored, you can easily switch to another application insights, shown in the below screengrab.

Microsoft account

Step 12. The time range filter option will help to get the last log information within the selected time range options.

Last thirty minute

Step 13

  1. Statistics graphs will be separated and presented, which includes collection-level colors.
  2. This is an easy way to get the collection level for selected logs, as shown in the below screenshot.
  3. Request details for selected details.
  4. The collection-level log information will be displayed here.
    Get weather force

In the next article, we learn how to access application insights app service on the portal level, here.

Happy Logging Application Insights In MVC Core, Web API Core And Entity Framework Core