This blog post is all about section two in the Develop an Instrumentation Strategy, Design and Implement Telemetry. It goes over what you would think by the title, telemetry. It starts off with distributed tracing and performance indicators, then moves into key metrics for things like CPU, memory, disk, desktop, email, SMS, webhooks, and messaging. Following that is where you will see user analytic data.
I really enjoyed this section. The previous section, Design and implement logging, was just too high level. A lot of other engineers and trainers I spoke to felt the same way. It was almost like it was thrown together in a sense.
This section primarily went over how to get data about data on an environment. It's extremely useful for any type of application. Whether you're running on virtual machines, serverless, containers, telemetry is needed to know what an application is doing and what the application is talking to.
Overall, definitely a solid and fun section in the AZ-400.
Tech Tips and Study Notes
Distributed tracing is the equivalent of call stacks for modern cloud and microservices architectures, with the addition of a simplistic performance profiler thrown in. In Azure Monitor, we provide two experiences for consuming distributed trace data. The first is our transaction diagnostics view, which is like a call stack with a time dimension added in. The transaction diagnostics view provides visibility into one single transaction/request, and is helpful for finding the root cause of reliability issues and performance bottlenecks on a per request basis.
Azure Monitor also offers an application map view which aggregates many transactions to show a topological view of how the systems interact, and what the average performance and error rates are.
Distributed Tracing can be done in most SDKs supported by Azure. We'll take a look at implementing in .NET Core.
Open up a terminal and create a new C# Web API boiler plate.
dotnet new webapi -o webapitest
Open your ASP.NET Core Web App project in Visual Studio > Right-click on the AppName in the Solution Explorer > Select Add > Application Insights Telemetry.
Configure a dependency.
Create a new Application Insights.
Configure app insights with the defaults so the web API can communicate with app insights.
Once you click Finish, the configuration will process successfully.
Next, start the application without debugging in Visual Studio and open up application insights. You will see telemetry, AKA, insights on the dashboard.
Inspect Application Performance Indicators with Web Apps
Enabling monitoring on your ASP.NET and ASP.NET Core based web applications running on Azure App Services is now easier than ever. Whereas previously you needed to manually install a site extension, the latest extension/agent is now built into the app service image by default.
Deploy the web app from the previous section to Azure. You can do this by right clicking the project and clicking Publish. You will then be prompted to choose where you want to publish. Ensure you're publishing to an Azure App Service (Windows).
Once the web app is deployed, you can configure application insights to run on the web app. Under Settings, go to Application Insights.
Once under Application Insights, you can enable app insights for the web app.
Once application insights is created, you can check performance in two key places:
- Investigate --> Performance
- Monitoring --> Metrics
Inspect infrastructure performance indicators with Virtual Machines
Azure Monitor for VMs includes a set of performance charts that target several key performance indicators (KPIs) to help you determine how well a virtual machine is performing.
To view performance for virtual machines, you'll first need to create one from the Azure virtual machine blade. Once the virtual machine is created:
- In the Azure portal, select Monitor.
- Choose Virtual Machines in the Solutions section.
- Select the Performance tab.
- Click on the virtual machine
5. Click on the Performance tab.
You can now see all performance counters for the virtual machine.
Define and Measure Key Metrics
Metrics in Azure Monitor are lightweight and capable of supporting near real-time scenarios making them particularly useful for alerting and fast detection of issues. This article describes how metrics are structured, what you can do with them, and identifies different data sources that store data in metrics.
Data collected by Azure Monitor Metrics is stored in a time-series database which is optimized for analyzing time-stamped data. Each set of metric values is a time series with the following properties:
- The time the value was collected
- The resource the value is associated with
- A namespace that acts like a category for the metric
- A metric name
- The value itself
- Some metrics may have multiple dimensions as described in Multi-dimensional metrics. Custom metrics can have up to 10 dimensions.
Within Azure Monitor, click the Metrics option.
Choose your scope and click the blue Apply button.
Choose a metric, for example, CPU Credits Consumed. As you can see from the screenshot below, you will now be able to see a key metric.
Implement Alerts on Key Metrics
Metric alerts in Azure Monitor provide a way to get notified when one of your metrics crosses a threshold. Metric alerts work on a range of multi-dimensional platform metrics, custom metrics, Application Insights standard and custom metrics.
- In Azure Portal, click on Monitor.
- Click Alerts then click + New alert rule.
3. Under the select a resource scope, choose a virtual machine.
4. Under conditions, choose the appropriate condition. For example, Percentage CPU over 20%.
5. Specify the alert rule name, description, and severity.
6. You will now see your new alert rule.
Another great way to set up alerting is with logic apps. Azure Logic Apps is a cloud service that helps you schedule, automate, and orchestrate tasks, business processes, and workflows when you need to integrate apps, data, systems, and services across enterprises or organizations.
To create a new logic app:
- Go to the Logic Apps blade in Azure.
- Create a new logic app with the appropriate subscription, resource group, logic app name, and region.
- Open up the logic app and go to Logic app designer.
4. Search for Azure Event Grid and for the trigger, choose When a resource event occurs. Ensure to sign in with an Azure account.
Below is a screenshot of what a blank resource event will look like.
5. You can choose the resource type, name, and what type of event has to occur to receive a message. For example, I can choose
Microsoft.Web.Sites to interact with Azure App Services and the event type can be when a web app is updated.
Once complete, choose the new step button and search for Gmail. You can set up an email, for example, to have an email sent to you when this occurs.
6. Choose Save and then click run.
7. Go to the web app and perform any update you wish. Once you do, you will receive an email.
Integrate User Analytics
There are a few different ways to retrieve user analytics. There is Google Analytics, TestFlight, Google Analytics, and many others. In Azure, Application Insights has a Users usage metric as well.
User analytics are essentially to see what the user is doing. How they are performing on the site, or what they're doing in a portal. It also includes where the users are coming from. Below is a screenshot of user analytics for Google Analytics on my mind. As you can see, users come from all over the world.
Google Analytics will also show the user count, new sessions, bounce rate, average session duration, and many other statistics.
Application Insights funnels are essentially the same thing, in terms of what analytics are, but instead gives you them based on Azure resources.
Create an Azure app service and deploy this movie app from GitHub to it. Ensure to have an application insights attached to the app service.
Once the web app is deployed, browse to it. Any page and nothing specific. Then in Application Insights, go to Usage -> Users
You will now see the one user (you) and the statistics on the user.
Once more way to check out user analytics is via Application Insights Funnels.
Understanding the customer experience is of the utmost importance to your business. If your application involves multiple stages, you need to know if most customers are progressing through the entire process, or if they are ending the process at some point. The progression through a series of steps in a web application is known as a funnel. You can use Azure Application Insights Funnels to gain insights into your users, and monitor step-by-step conversion rates.
While still in Application Insights, click on Usage -> Funnels