Application Insights Customisation And OMS Integration

In this post I’ll be taking a look at Application Insights customisation and OMS Integration.

Custom Dashboards

You can pin the out-of-the-box charts to your Azure Portal dashboard by clicking on the pin in the top right corner. Analytics query charts can also be pinned using the same method but they are pinned to shared dashboards. Shared dashboards exist as an Azure resource in a resource group and you can use RBAC to control access to it.

Application Insights Customisation And OMS Integration

Alerts

You can create alerts based on the telemetry in Application Insights, you will find the Alert Rule button in the Metrics Explorer blade.

Application Insights Customisation And OMS Integration

 

Currently you can only create alert rules based on out-of-the-box telemetry but not from custom events or analytics queries. Good news is the feature is in preview so it should be available soon, link to uservoice.

Correlating Entries And Custom Properties

By default Application Insights populates the operation_id for every web request and propagates that operation_id to dependencies that it is able to trace out -of-the-box for example SQL Server queries and WCF calls to HTTP endpoints. The example below is for SQL Server queries joined to web requests.

Application Insights Customisation And OMS Integration

If you have a dependency that Application Insight can’t trace automatically or you have multiple levels of dependencies you have to provide your own solution to propagate the operation_id or your own contextual identifier like customer id. You can do this by creating a TelemetryInitializer to add your custom id or to grab the web request id and pass it along to the other services, example here.

OMS Integration

You can view and query your Application Insights telemetry in OMS by installing the OMS Application Insights solution from the OMS portal and configuring which applications you want to connect from Application Insights.

Application Insights Customisation And OMS Integration

You can connect multiple applications from different subscriptions which makes it easy to create a consolidated view. You can correlate Application Insights telemetry with other data sources in OMS like infrastructure telemetry making it easier to pinpoint the cause of slow application response.

VSTS Integration

You can install Application Insight widgets on your VSTS dashboards to surface Application Insight data in VSTS, link to marketplace.

PowerBI Integration

There is a content pack to create PowerBI dashboards with telemetry from Application Insights, link here. The content pack comes with a set of built-in dashboards. If you need a custom dashboard you can export Analytics Queries to PowerBI as explained here.

Custom Telemetry

Contextual logging and telemetry that makes sense in a business context for instance orders completed per second or aborted shopping carts can be a very powerful tool to get useful information out of logs and to track problems related to a specific customer interaction. To achieve this you can add your own telemetry to Application Insights by writing custom events and logging exceptions, link here. You can also have your favorite logging library writing to Application Insights, examples here.

Francois Delport

Adding Application Insights To Existing Web And Service Applications

In this post I’m going to take a quick look at adding Application Insights to existing web and service applications. I’m going to highlight a few things I discovered and explore the difference between the two approaches.

Adding Application Insights During Development Or Post Deployment

There are two ways to add Application Insights to your application:

  • During development you can use the Application Insight SDK and wizard in Visual Studio to add it to your web application.
  • After deployment you can enable Application Insights using the Status Monitor application or PowerShell.

The web application I’m working on is tied to Visual Studio 2012 and Visual Studio 2013 or higher is required for the wizard in Visual Studio, hence the investigation to add Application Insights to deployed applications. Enabling Application Insights post deploy can also be handy for web applications where you don’t have access to the source or you are not allowed to make any changes. I followed the instructions here.

Some Difference Between The Two Methods

  • When you add Application Insights to your project using the wizard in Visual Studio it will install additional nuget packages, references and configuration settings to send telemetry data to Azure. For deployed applications you have to install the StatusMonitor application to configure Application Insights or use PowerShell. Application Insights will keep it’s configuration in an ApplicationInsights.config file in your web app root folder and some nuget packages in your App_Data folder and additional dlls in the bin folder.

Adding Application Insights To Existing Web And Sevice Applications

The configuration file, dlls and packages can be  be lost when you redeploy.

Side Note: You can use Application Insights locally to view telemetry data in Visual Studio without configuring Application Insights in Azure or sending any telemetry data to Azure.

  • Application Insights can monitor client side events if you add some Javascript snippets to your pages, it can provide more detailed telemetry and you can create custom telemetry entries using the SDK. For deployed applications you only get the telemetry that IIS and .NET provides by default.

How To Add Application Insights Post Deployment Using PowerShell

Obviously loosing your Application Insights configuration after deploying is not an ideal situation, luckily you can easily script the configuration using PowerShell.

Import-Module 'C:\Program Files\Microsoft Application Insights\Status Monitor\PowerShell\Microsoft.Diagnostics.Agent.StatusMonitor.PowerShell.dll'
#optional
Update-ApplicationInsightsVersion    

Start-ApplicationInsightsMonitoring -Name appName -InstrumentationKey {YourInstrumentationKeyFoundInTheAzurePortal}

#optional
Get-ApplicationInsightsMonitoringStatus

The Update command is optional and updates the version of Application Insights installed before adding it to the application. The Get command is also optional making it easy to see the status information in your VSTS deployment log.

Adding Application Insights To Service Or Desktop Applications

For non-web applications it can’t be done after deployment, you have to add the Microsoft.ApplicationInsights.WindowsServer nuget package during development and configure the InstumentationKey in your code, instructions here.

Side Note: Application Insights is billed by usage and the first GB of telemetry data is free, making it easy to experiment or even use on small applications permanently. You can use sampling to limit the telemetry data and configure a daily limit in the portal to make sure you stay in the free tier.

Francois Delport