Azure Application Insights

When an application is hosted for customers to use, we have to continuously monitor the performance. Application performance monitoring ensures that the hosted application is performing as expected without any errors. We have to quickly find out the issues that impact the application negatively and figure out the solutions for them. Azure provides a feature called Application Insights as part of Azure Monitor. It widely helps developers in monitoring the applications. In this post, we will give a brief understanding of what Azure Application insights service is and how it works. We will also show you how to enable the service.

What is Azure Application Insights?

Application Insights is an Application Performance Management (APM) service for developers to monitor live applications. The anomalies in performance are automatically detected. It also includes powerful analytics tools that help in diagnosing issues. The insights help to understand how users are interacting with the application. With the Application Insights, developers can continuously improve performance and usability.

Application Insights works on applications built with various languages like .NET, Node.js, Java, and Python. The applications can be hosted on-premise or on the cloud, or hybrid. It can integrate with DevOps processes. It also integrates with Visual Studio App Center and can monitor telemetry from mobile apps.

All the data in the Application insights service can be exported to a database or any external tools. Application Insights SDKs are available for web services hosted in ASP.NET servers, Java EE, Azure. They are also available for web clients, desktop apps, mobile devices like Windows Phone, iOS, and Android.

Learn More about Azure app Serviece

How does it work?

To monitor your application, all you have to do is enable the Application Insights from the Azure portal or install a small instrumentation package (SDK) in your application. The application will be monitored by this instrumentation package. It will use a unique GUID, which is also known as an Instrumentation Key, to direct the telemetry data to an Application Insights resource.

IMAGE

Since we install the instrumentation package in the application, it doesn't have to be hosted on Azure. The application can run anywhere. We can instrument any background components of an application and the JavaScript in the web pages too. Application Insights can also collect telemetry data from Azure diagnostics, Docker logs, or performance counters when they are integrated into Azure Monitor. 

Interested in learning Azure Course ? Enroll in our Microsoft Azure Certification Training program now!

What does the Application Insights monitor?

Application Insights focuses on the performance of an application to ease the work of the development team. It monitors the following constraints,

  • Request rates, response times, and failure rates - It tells us which pages are being visited the most and at what times of the day.
  • Dependency rates, response times, and failure rates - It shows any external sources that might slow the application down.
  • Exceptions - It reports both server and browser exceptions. It gives an aggregate statistics of all the instances. We can further drill down to get statistics of individual instances.
  • It will also monitor the page views and load performance collected from the user's browser.
  • It monitors AJAX calls from web pages, users, and session counts.
  • It will show the performance of memory, CPU, and network usage.
  • We can get host diagnostics from Docker or Azure.
  • We can correlate events with requests using the diagnostic trace logs of the application.
  • It also shows the custom events or metrics that the developer includes in the code.

Uses of Application Insights

Once we install Application Insights for an application, we can get the following benefits.

  • The load, responsiveness, and the performance of page loads, dependencies, AJAX calls can be known through an intuitive application dashboard.
  • We can identify the slowest requests and determine the requests that are failing often.
  • When a new release of an application is deployed, the statistics of it can be seen through a live stream.
  • If users are affected, we can get an alert so we can check how many users are being affected.
  • If there are any request failures, we can correlate them with the exceptions, dependency calls, and traces.
  • When a new feature of the app has to be deployed, we can measure the effectiveness of it.

Microsoft Azure Certification Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

Limitations of Azure Application Insights

Like any other solution, Application Insights has some limitations.

  • If your code uses dynamic SQL, the Application Insights collects the full query into Azure, which might result in uploading sensitive data contained in the query.
  • The reports show up to the server and database level. But it cannot monitor individual SQL queries on how long they are being executed.
  • When you add Application Insights and deploy the application to Azure, it won't collect the SQL queries unless a site extension is installed for it.
  • It cannot collect first chance exceptions.
  • It cannot show common exceptions across all applications.
  • If you are using ASP.NET for your application, Application Insights does not support asynchronous HttpClient calls.
  • There is no alert severity specified.
  • We cannot configure alerts to go to specific distribution lists based on severity.

Data collection, retention, and storage of Application Insights

When Azure Application Insights SDK is installed in your application, it starts sending telemetry data from your app to the cloud. Each SDK uses different techniques to collect telemetry data from different kinds of applications. You can also include custom telemetry to send your data. Azure runs some processes called availability tests to web applications regularly. The results from the test will be sent back to the Application Insights service. 

                                                 Get ahead in your career with our Microsoft Azure Tutorial  

You can test which data is being sent by the SDK. You can view the data in the output windows of the IDE and browser while testing the application. The data in the Application Insights service can retain up to 730 days. Users can set up a retention duration. The debug snapshots are stored for 15 days in the Application Insights service.

If the SDK is not able to reach the endpoint, the telemetry channels store the data in local storage temporarily by creating temp files. Once the issue is resolved, the new data, along with the persisted data, will be sent to Azure by the telemetry channel.

Subscribe to our youtube channel to get new updates..!

Enable Application Insights for your application

Create Application Insights service

Navigate to the Azure portal at https://portal.azure.com/ and login to your account. Click on '+ New' from the left side menu. Search for 'Application Insights' in the search bar. You can see the service in the search results. Click on it to open the service and click on 'Create'. Give a name for your service, select your application type from the drop-down menu, and select your subscription. Choose 'Create new' for the 'Resource Group' field and give the same name that you gave for the service. Select a location and click on 'Create'.

                                         Learn new & advanced  Architect solutions in hkr's  Azure Architect solutions course

Go to the newly created resource group and click on 'app insights resource'. You will get the details of the resource. Copy the 'Instrumentation Key' from the page.

Add the Instrumentation key to the application

Open Visual Studio and navigate to the appsettings.json file of your application. Add the below code in the file.

"Application Insights": {
"InstrumentationKey": "Your_instrumentation_key"
}

Replace the 'Your_instrumentation_key' with the one you copied before. It appears as a NuGet package. Go to the package.json file in your application, and you can see the Application Insights package added. You have successfully configured Application Insights to your application.

View the telemetry data

Launch the application from Visual Studio and play around with it. Stop the application. Right-click on the application, select 'Application Insights', and select the 'Search Debug Session Telemetry' option. You can see the telemetry data captured by your application. You can also see the details in Application Insights. Right-click on the application, select 'Application Insights', and select the 'Open Application Insights Portal' option.

The Application Insights portal opens up, and you can see the telemetry data collected from your application. You can drill down to see the page load metrics and more.

Microsoft Azure Certification Training

Weekday / Weekend Batches

Conclusion

Application Insights is a simple way for developers to detect and diagnose application performance issues of live applications. The SDKs vary for different applications and different platforms. Each SDK component sends different data. So choose one that is suitable for your application and install it. You can also include code in your application to send unhandled exceptions. The Azure Application Insights has a built-in map feature that can be used to identify the performance of dependencies.

Related Articles:

Azure app service

Azure Traffic manager 

Azure Certification Path

Categories

SAP

Request for more information

Webinar

Register Free Live Sonicwall Webinar

25th October | 12:00 am

0 Registered

Sachin
Sachin
Networking, OS, Salesforce & Sap
Am sachin I have worked with hkr trainings for more than 4 years .and our methodologies had been a practical suit for student culture and professionals. And I have trained more than 30 batches over the last 8 months. And I have great experience working with hkr trainings. Contact me with my LinkedIn and Twitter.

WhatsApp
To Top