Monitor Azure Static Web Apps
Enable Application Insights to monitor API requests, failures, and tracing information.
Important
Application Insights has an independent pricing model from Azure Static Web Apps.
Note
Using Application Insights with Azure Static Web Apps requires an application with an API.
Add monitoring
Use the following steps to add Application Insights monitoring to your static web app.
Open the Static Web Apps instance in the Azure portal.
Select Application Insights from the menu.
Select Yes next to Enable Application Insights.
Select Save.
Once you create the Application Insights instance, it creates an associated application setting in the Azure Static Web Apps instance used to link the services together.
Note
If you want to track how the different features of your web app are used end-to-end client side, you can insert trace calls in your JavaScript code. For more information, see Application Insights for webpages.
Access data
From the Overview window in your static web app, select the link next to the Resource group.
From the list, select the Application Insights instance prefixed with the same name as your static web app.
The following table highlights a few locations in the portal you can use to inspect aspects of your application's API endpoints.
Note
For more information on Application Insights usage, see the App insights overview.
Type | Menu location | Description |
---|---|---|
Failures | Investigate > Failures | Review failed requests. |
Server requests | Investigate > Performance | Review individual API requests. |
Logs | Monitoring > Logs | Interact with an editor to query transaction logs. |
Metrics | Monitoring > Metrics | Interact with a designer to create custom charts using various metrics. |
Traces
Using the following steps to view traces in your application.
Select Logs under Monitoring.
Hover your mouse over any card in the Queries window.
Select Load Editor.
Replace the generated query with the word
traces
.Select Run.
Limit logging
In some cases, you may want to limit logging while still capturing details on errors and warnings. You can do so by making the following changes to your host.json file of the Azure Functions app.
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
},
"enableDependencyTracking": false
},
"logLevels": {
"default": "Warning"
}
}
}