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.
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.
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!
Application Insights focuses on the performance of an application to ease the work of the development team. It monitors the following constraints,
Once we install Application Insights for an application, we can get the following benefits.
Like any other solution, Application Insights has some limitations.
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.
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.
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.
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.
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:
Batch starts on 27th Sep 2023, Weekday batch
Batch starts on 1st Oct 2023, Weekend batch
Batch starts on 5th Oct 2023, Weekday batch