Tag: Application Insights

Azure

Overview of Monitoring in Azure

Monitoring, monitoring, monitoring! In my opinion as a Systems Architect and Developer for the last 20 years I’ve found that we don’t do enough application and resource logging. It’s only when you start working with DevOps and see how the operations team works with and troubleshoots your applications do you as a developer realize that maybe we should have added more logging to help diagnose and provide valuable insights to the state of your application.

Luckily for us when you deploy your application to Azure there is a breadth of monitoring solutions for collecting, analyzing and acting on telemetry from your application and the Azure resources that support them. These services are categorized into the following four sections:

  • Deep Application Monitoring
  • Deep Infrastructure Monitoring    
  • Core Monitoring    
  • Shared Capabilities

Monitoring overview

Deep Application Monitoring

Application Insights provides deep insights into your application performance, availability and usage, whether you have it hosted in the cloud or on-premises. Application Insights provides the capability to instrument your own applications, adding events to suit your own needs. Application Insights can be configured for new applications or you can start monitoring an existing application in production without any changes by using an agent.

Application Insights provides you with the ability to quickly identify and diagnose issues in production and can also be used for local and/or QA testing.

When leveraging Application Insights you can take advantage of Application Insights Analytics to detect trends, identify usage behaviors, and perform complex queries, and Application Insights is built upon core monitoring services found in Azure.

Deep Infrastructure Monitoring

On the infrastructure side we have Deep Infrastructure Monitoring is made up Log Analytics, Management Solutions, Service Map, and Network Monitoring which is made up by several tools that work together. These services also build upon core monitoring services in Azure that provide powerful analytics.

Core Monitoring

Core monitoring is standard across Azure resources and require only minimal configuration. Core monitoring provides the necessary telemetry that the premium monitoring services leverage. With Core monitoring we have access to Azure Monitor, Azure Advisor, Azure Service Health, and Activity Logs.

Shared Capabilities

Finally we have the shared monitoring capabilities that the core and deep monitoring services use to provide features like Alerts, Dashboards, and the Metrics Explorer.

Summary

Monitoring is an essential role in any application so that you can collect and analyze data to determine the performance, health and availability of your application and the resources that it depends on. Azure provides a very robust set of services from monitoring your application all the way down to the infrastructure it runs on.

Enjoy!

Resources

Azure Monitoring Docs

Overview of Monitoring in Azure 

Explore Azure Monitor to get started with core monitoring metrics and alerts

Explore Application Insights if you’re trying to diagnose problems in your App Service web app

Explore Log Analytics for analyzing collected monitoring data and logs

Development

Getting Started with Application Insights for ASP.NET Core

In my previous posts I gave a quick Introduction to Application Insights and then I showed you how to Disable Application Insights from your app. In this post I’ll walk you through creating an ASP.NET Core application and then configuring it with Application Insights. Let’s get started.

Configuring your app for Application Insights

Start by creating a new ASP.NET Core application (this also applied to non-core ASP.NET applications). Once the application is created right click on the project file in the context menu look for Configure Application Insights… and then click on it.

image

You will see that the SDK has already been added to your application. Next click on the Start Free button to start using Application Insights.

image

You will need to have an existing Azure Subscription. If you don’t already have one you can create one for free and start with a $250 credit for 30 days + you will have access to popular services for 12 months + there are over 25 services that are always free. Now that you have your Azure Subscription, login with your Microsoft Account, select your Subscription and then a Resource. These can always be easily changed later on if need be.

You will now have access to the free plan which comes with 1 GB / Month of data included and data retention is 90 days. Click on he Register button to finish the configuration:

image

Now that Application Insights is configured for your application you have access to a wealth of information with the click of a button.

sshot-372

Accessing the Application Insights Telemetry from Visual Studio

You can search your Application Insights results from either the Azure Portal or from within Visual Studio. To use Visual Studio go to the View menu, select Other Windows and then Application Insight Search. You will then get view of the telemetry for the last 24 hours as shown below from a sample API I have. From here you can filter the telemetry and dive down into specific events.

image

Another nice feature is that Application Insights telemetry data including any exceptions that have been captured will show up in the CodeLens information as shown here:

image

There is a lot of value from using Application Insights in any of your applications. I hope you take a look and try it out for yourself.

Enjoy!

References

https://azure.microsoft.com/en-us/services/application-insights/

https://docs.microsoft.com/en-us/azure/application-insights/app-insights-asp-net-core

Development

How to Disable Azure Application Insights in ASP.NET Core

In my previous post I showed you how easy it was to get started with an Introduction to Application Insights for your ASP.NET Core application. However what if you you don’t want Application Insights? You might notice in your Output pane when running your app that it’s still partially enabled for you out of the box. I’ll walk you through what I mean by it being partially enabled and then how you can go about hiding it until such time you decide to fully turn it on. Let’s get started.

Start off by creating a new ASP.NET Core application (see below) and then immediately run it.

image

You will then notice that you will see the following statements in your Output pane:

Application Insights Telemetry (unconfigured): {“name”:”Microsoft.ApplicationInsights.Dev.Message”,”time”:”2018-03-24T03:39:26.5327026Z”,”tags”:{“ai.application.ver”:”1.0.0.0″,”ai.operation.parentId”:”|80d77757-4707b4b80d71a9b3.”,”ai.internal.sdkVersion”:”aspnet5c:2.1.1″,”ai.operation.id”:”80d77757-4707b4b80d71a9b3″,”ai.internal.nodeName”:”LT2206″,”ai.location.ip”:”127.0.0.1″,”ai.cloud.roleInstance”:”LT2206″,”ai.operation.name”:”GET Values/Get”,”ai.user.id”:”6RWa2″},”data”:{“baseType”:”MessageData”,”baseData”:{“ver”:2,”message”:”Executed action WebApplication5.Controllers.ValuesController.Get (WebApplication5) in 205.1085ms”,”severityLevel”:”Information”,”properties”:{“DeveloperMode”:”true”,”{OriginalFormat}”:”Executed action {ActionName} in {ElapsedMilliseconds}ms”,”ActionName”:”WebApplication5.Controllers.ValuesController.Get (WebApplication5)”,”AspNetCoreEnvironment”:”Development”,”ElapsedMilliseconds”:”205.1085″,”CategoryName”:”Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker”}}}}

image

You might be wondering why is it doing this and how can I disable it?

The easiest way to disable Application Insights without going through the process of ripping it out is to just disable it. You can do this by accessing TelemetryConfiguration.Active.DisableTelemetry and setting this to true. What I would recommend doing is to add a static method to your Startup.cs file and call this method from your Configure method like so:

image

Now when you run your application and look in the Output pane you will no longer see any statement pertaining to Application Insights.

image

I see a great deal of value of keeping Application Insights and using it in all your applications, so if you need to disable it then maybe do this when running in debug mode by using a conditional attribute on the method.

Enjoy!

References

https://github.com/aspnet/Home/issues/2051

Azure

Introduction to Application Insights

Application Insights gives you the deep diagnostics and performance information you need to take control of your web apps, and bring sanity back to your life. Get actionable insights through application performance management and instant analytics.

image

What can you do with Application Insights ?

  • Detect and diagnose exceptions and application performance issues
  • Get answers to your tough questions, and take your applications to the next level
  • Detect trends in application performance and behavior, identify usage patterns, and get fast answers to probing questions about your website performance
  • Monitor Azure websites, including those hosted in containers, plus websites on-premises and with other cloud providers
  • Seamlessly integrate with your DevOps pipeline using Visual Studio Team Services (VSTS), GitHub, and webhooks
  • Quickly get started from within Visual Studio, or monitor existing applications without redeploying

Azure Application Insights is included with Visual Studio. You get automatic instrumentation for ASP.NET applications and application telemetry data right out of the box—including usage, exceptions, requests, performance, and logs.

Pricing Models

There are two offerings for Application Insights – Basic, and Enterprise.

With Basic, you pay based on the volume of telemetry your application sends, with a 1 GB free allowance per month. This free data allowance gives you a great way to try out Application Insights as you get started, and it also allows you to use Application Insights for free on an ongoing basis for debugging and low-volume applications.

In the Enterprise pricing option, you pay for the number of nodes that host your application, and you get a daily allowance of data per node. Additional data beyond the daily allowance is charged per GB. A “node” is a server, or Platform-as-a-Service instance that runs your application, and from which we receive telemetry.

The Enterprise option also provides unlimited, continuous export of data at no extra charge.

Summary

With Application Insights there is no upfront cost, no termination fees, and you only pay for what you need.

In my next post I’ll show you how easy it is to setup Application Insights with your application.

Enjoy!

References

https://channel9.msdn.com/Blogs/Azure/Application-Insights-Animated-Introduction

https://azure.microsoft.com/en-us/pricing/details/application-insights/

http://aka.ms/getapplicationinsights

Documentation

Azure

Azure Functions now with Application Insights integration

Earlier this month Azure Functions was updated to have direct integration with Application Insights and is currently only available on the “beta” version of Azure Functions. At this time it’s recommended to only try this out in non-production Azure Function apps until it’s a more stable release.

Getting Started

Before we can enable Azure Function Application Insights integration, we will need to setup an Application Insights instance. If you already have one skip to the next step.

  1. Create an Application Insights instance and Application Type should be General. Once your Application Insights is setup, copy the instrumentation key which we’ll need in the next step.
    image
    image
  2. Next you will need to update your Azure Function Application Settings to configure your function to run under the “beta” version and then to set your Application Insights Instrumentation Key.image
  3. Now go to Application Settings and then update App Setting “FUNCTIONS_EXTENSION_VERSION” from “~1” to “beta” and then add a new key named “APPINSIGHTS_INSTRUMENTATIONKEY” and set the value to the Application Insights Instrumentation key you copied in step 1. Now click Save to update your Azure Function.
    image 

Once this is done, your Application Insights instance will start collecting telemetry from your Azure Function without any code changes.

Using Application Insights

Going to your Application Insights, you can start to see some metrics showing up on the overview blade:image

Live Metrics Stream

You can get a lot more insights to real-time telemetry from the Live Metrics Stream to see what’s happening right now:
image

Analytics

Another great resource of Application Insights is the Analytics portal, which provides you the ability to write your own custom queries.
image

Alerts

The previous two options are great to see what is happening or what happened historically, but Alerts will tell you what’s happening. I suggest you checkout Alerts from the Application Insights blade, where you can define alerts based on a wide array of metrics.

image

Summary

You can now add Application Insights to your Azure Functions with minimal effort, which is a powerful tool for monitoring your applications. Keep in mind that this is currently only available in the “beta” version of Azure Functions, but is something that should be coming to the production release in the near future now that it’s been merged into the develop branch on github.

Enjoy!

References

Azure Functions integration with Application Insights

Azure Functions now has direct integration with Application Insights

Application Insights

Live Metrics Stream docs