Endpoint Monitoring with Azure Application Insights
Tags: azure, devops, architecture, microservices
Published: 2020-09-28 15:37:40

Let's work with **Application Insights** - a **Microsoft Azure** service - to monitor our application endpoint `/healthcheck`.

This is the third article about Health Checks and Application Monitoring.

Also, check out my blog at https://rmauro.dev

This article assumes that you have a *Health Checks* endpoint up and running available over the internet. 

If not go back to this [article](https://rmauro.dev/adding-health-checks-to-net-core-application/) to set up and them return here.
*The Health Check UI is not necessary for this article, only the API endpoint.*

## Introduction

Applications Insights it's a great tool for monitoring, error logging, performance monitor, dependency mapping, and other things. In other words, it's a fully APM - Application Performance Management.

> Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals.
https://docs.microsoft.com/pt-br/azure/azure-monitor/app/app-insights-overview

## Requirements
Our API should be available over the internet (Application Insights should have access to hit it).

I published mine at https://webapphealthchecks.azurewebsites.net/

You can use it for testing purposes if you like.

## Creating Application Insights Resource

Access the Azure Portal at https://portal.azure.com and access the Application Insights blade and then click Add to create a new resource.

![Create Application Insights Resource](https://res-5.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/portal-azure.png)

Enter all the required information to create the resource, such as subscription, resource group, etc. When asked for the Resource Mode choose the Classic.

![Creating-AI](https://res-5.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/ai-create-1.png)

Once the Application Insights it's created, go to the Availability section. This is where the monitoring tool is configured to watch our endpoint.

![Go to Availability](https://res-2.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/ai-created.png)

Now click on the `+Add Test` button.

![Adding Test](https://res-3.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/AI-create-test.png)

Fill the required information.

- Test name: *AI-Ping-WebApp*
- Test Type: *URL ping test*
- URL: *https://webapphealthchecks.azurewebsites.net/healthcheck*
- Parse dependent requests: *unchecked*
- Enable retries for availability test failures: *checked*
- Test frequency: *5 minutes*
- Test locations: *default values*
- Test Timeout: *120 seconds*
- HTTP Response: *checked*
- Status code must equal: *200*
- Content match: *checked*
- Content must contain: *Healthy*
- Alerts: *leave default value*

And them **Create**.

![Creating the test](https://res-2.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/ai-ping-test-full-2.png)

Now just wait for the tests begin and show the results. After a few minutes, you should get something like this.

![Line View Test Results](https://res-3.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/ai-ping-test-result.png)

![Scatter Plot Test Results](https://res-3.cloudinary.com/ht54oxr6q/image/upload/q_auto/v1/ghost-blog-images/ai-ping-test-result-2.png)

That is it!
Leave a comment if you have any questions or like it.