Lab 02: Implementing Real-Time Monitoring with Azure Monitor
Estimated timing: 20 minutes
Prerequisites
- Azure subscription - If you don’t have an Azure subscription, create a free account.
- Basic knowledge of monitoring and observability concepts.
- Basic understanding of Azure services.
Objectives
- Create a sample web app.
- Enable and configure Azure Monitor and Application Insights.
- Create custom dashboards to visualize application metrics.
- Set up alerts to notify stakeholders of performance anomalies.
- Analyze performance data for potential improvements.
Exercise 1: Create a sample web application
As a platform engineer, you need to ensure the applications running on your platform are observable and continuously monitored. In this lab, you will create a sample web application to Azure, configure Azure Monitor and Application Insights, set up custom dashboards, and create alerts to track application performance.
Task 1: Create an Azure Web App
- Open the Azure portal.
- In the Search bar, type App Services and select it.
- Click + Create and select Web App.
- In the Basics tab:
- Subscription: Select your Azure subscription.
- Resource Group: Click Create new, enter
monitoringlab-rg
, and click OK. - Name: Enter a unique name, such as
monitoringlab-webapp
. - Publish: Select Code.
- Runtime stack: Choose .NET 8 (LTS).
- Region: Select a region close to you.
- Click Review + create, then click Create.
- Wait for deployment to complete, then click “Go to resource”.
- In the Overview tab, click the URL to verify the web app is running.
Task 2: Verify Application Insights
- In the Web App resource, scroll to the Monitoring section.
- Click Application Insights.
- Application Insights is already enabled for this web app. Click the link to open the Application Insights resource.
- In the Application Insights resource, click in the Application Dashboard to view the performance data the default dashboard provided.
Exercise 2: Configure Azure Monitor and dashboards
Task 1: Access Azure Monitor
- In the Azure portal, search for Monitor and click on it.
- Click Metrics in the left panel.
- In the Scope section, select the web app under the subscription and resource group where you deployed the web app.
- Click Apply and observe the metrics available for the web app.
Task 2: Add key metrics to the dashboard
- In the Scope section, select your Web App (monitoringlab-webapp).
- Under Metric, choose Response Time.
- Set the Aggregation to Average and click + Add metric.
- Repeat the process for additional metrics:
- CPU Time (Count)
- Requests (Average)
- Click to dashboard and pin to dashboard.
- Select type Shared and select the subscription and the monitoringlab-webapp Dashboard.
- Click Pin to dashboard.
- Click the dashboard icon in the left panel to view the dashboard.
- Verify the metrics are displayed on the dashboard and are updating in real-time.
Exercise 3: Create alerts
Task 1: Define alert conditions and actions
- In Azure Monitor, click Alerts.
- Click + Create and select Alert rule.
- Under Scope, select your Web App (monitoringlab-webapp) and click Apply.
- Under Condition, click in the Signal name field and select Response Time.
- Configure the alert rule:
- Threshold type: Dynamic
- Aggregation type: Average
- Value is: Greater or Less than
- Threshold Sensitivity: High
- When to evaluate: Check every 1 minutes and look back at 5 minutes.
- Under Actions, select Use quick actions.
- Enter:
- Action group name: WebAppMonitoringAlerts
- Display name: WebAlert
- Email: Enter your email address.
- Click Save.
- Click Next: Details.
- Enter a Name
WebAppResponseTimeAlert
and select a Severity level Verbose. -
Click Review + create and then Create.
Note: Your alert rule is now created and will trigger an email notification when the response time exceeds the threshold. You can force the alert to trigger by sending a large number of requests to the web app. For example, you can use Azure Load testing or a tool like Apache JMeter.
- Go back to the Azure Monitor > Alerts.
- Click on Alert rules and you should see the alert rule you created.
Exercise 4: Analyze performance data
Task 1: Review Collected Metrics
- Go to Application Insights in the Azure portal.
- Click on the Application Dashboard.
- Click Performance tile to analyze server response times and load. You can also view the number of requests and failed requests.
- Click on Analyze with Workbooks and select Performance Counter Analysis.
- Click Workbooks.
- Select the workbook Performance Analysis under Performance.
- You can see the performance data for the web app.
Note: You can customize the workbook to include additional metrics and filters.