Exercise - application performance monitoring

Completed

In this exercise, with zero configuration, you'll effortlessly monitor data flows for your sample application.

Monitor the Application with Azure Application Insights

Application Map helps you spot performance bottlenecks or failure hot-spots across all components of your distributed application.

  1. Open the Azure portal

  2. Select "Azure Spring Apps" from the list of Azure services

  3. Select your Azure Spring Apps instance

  4. Select Application Insights to jump to the overview page of Application Insights.

    screenshot showing Application insights for your spring apps

  5. On the left, navigate to Application Map where you can see a view of your Azure Spring Apps microservices:

    Screenshot showing Application map with microservices

Applications that are operating correctly (green) and those applications with bottlenecks (red). In the Application Map above, each of the names in green boxes are different services of your Azure Spring Apps. You can easily identify issues in their applications and quickly troubleshoot and fix them. Each node on the map represents a microservice or its dependencies with health KPI and alerts status. You can select from any component to more detailed diagnostics, such as Application Insights events.

Performance

  1. On the left, navigate to Performance where you can see response times and request counts for operations exposed by your applications.

    Screenshot showing operation performance view for your Azure Spring Apps instance.

  2. Next, on the right, navigate to Dependencies where you can see all your dependencies and their response times and request counts. You can see the performance number for dependencies, particularly SQL calls:

    Screenshot showing dependency performance view

  3. Select a SQL statement in the "Select operation tab" to see the transaction in context:

    Screenshot showing SQL transaction

  4. Next, on the Right tab, select "Drill into" and on the far right tab, and then select a SQL sample to open the transaction detail window:

    Screenshot showing SQL sample transaction

  5. Finally, in the transaction details view, view the sample sql statement transaction by selecting the sql statement:

    Screenshot showing SQL transaction detail

Failures/Exceptions

  1. Select Failures in the Application Insights resource menu located in the Investigate section. In this view, you'll see top three failure response codes, top three exception types, and top three failing dependency types.

    Screenshot showing Failures view for your Azure Spring Apps instance.

  2. On the right-hand side, select an exception in the "Top 3 exception types" for meaningful insights and actionable stack trace::

    Screenshot showing the exception screen

  3. Next, on the right tab, select the "Suggested" exception sample to open the transaction detail window:

    Screenshot showing the exception detail screen

  4. Next, view the exception properties in the transaction detail window:

    Screenshot showing the exception details screen

  5. Finally, in the middle of the screen, in the end-to-end transaction tab, select an exception to view its details and stacktrace:

    Screenshot showing the exception stacktrace screen

Metrics

Spring Boot registers many core metrics: JVM, CPU, Tomcat, Logback... You can see metrics contributed by Spring Boot apps, Spring Apps modules, and dependencies.

To create a standard metric chart, under the Monitoring section, open the Metrics tab and follow these steps:

  1. Ensure your Azure Spring Apps is selected under Scope and Azure Spring Apps under Metric Namespace. Both will already be populated if you opened the metrics explorer from the resource's menu.

    Screenshot showing metrics

  2. Next, under metrics, select App CPU Usage and under aggregation, select Avg:

    Screenshot showing adding app cpu metrics

  3. Next, save the first metric by selecting the "Tick" icon on the right-hand metric bar.

    Screenshot showing metrics selection

  4. Next, add another metric by selecting the "Add metric" action on the top left-hand toolbar and add system.cpu.usage under Metric and Avg under Aggregation.

    Screenshot showing adding system cpu metrics

  5. Next, save the second metric by selecting the "Tick" icon on the right-hand metric bar.

    Screenshot showing saving system cpu metrics

  6. Finally, inspect your metrics graph with both the App and System CPU metrics Screenshot showing system and app cpu metrics

Custom Metrics

As you deploy resources and applications in Azure, you'll want to start collecting telemetry to gain insights into their performance and health. Azure makes some metrics available to you out of the box. These metrics are called standard or platform. However, they're limited in nature. You might want to collect some custom performance indicators or business-specific metrics to provide deeper insights.

Similarly to standard metric chart, to create a custom metric chart, under the Monitoring section, open the Metrics tab and follow these steps:

  1. Ensure your Azure Spring Apps is selected in the resource scope picker. It will already be populated if you opened metrics explorer from the resource's menu.

  2. Next, under namespaces, select the azure.applicationinsights namespace. The namespace is just a way to organize metrics so that you can easily find them.

    Screenshot showing namespace selection for custom metrics

  3. Next, under metrics, add the following custom metrics and aggregation:

    • Metric petclinic_pet, Aggregation: count

      Screenshot showing metric and aggregate selection for custom metrics

    • Metric petclinic_owner, Aggregation: count

    • Metric petclinic_visit, Aggregation: count

      Screenshot showing finished custom metrics view

  4. Next, on the top right-hand side, change the graph type to Area Chart

    Screenshot showing graph type selection for custom metrics view

    Your final graph will show the counts in the last 24 hours for each of the pet, vet, and owner microservices:

    Screenshot showing final custom metrics view

Live Metrics

When you deploy a new version of your web app, you want to know immediately its effect on performance. Have response times improved or worsened, or is it showing failures? Watch Live Metrics Stream in Application Insights while your deployment is happening, and you’ll see the effect immediately. If there are problems, you could back out the deployment before too many users are affected. Live Metrics Stream enables you to probe the beating heart of your live applications. You can select and filter metrics and performance counters to watch in real time, without any disturbance to your service. You can also inspect stack traces from sample failed requests and exceptions.

  1. On the left, under the Investigate section, navigate to Live Metrics where you can see live metrics practically in real time, within only one second:

    Screenshot showing live metrics view for your Azure Spring Apps.

  2. Scroll down the metrics to see the metrics for each microservice:

    Screenshot showing Service live metrics view for your Azure Spring Apps.