title | description | services | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|
Monitoring Azure Static Web Apps |
Monitor requests, failures, and tracing information in Azure Static Web Apps |
static-web-apps |
craigshoemaker |
static-web-apps |
conceptual |
4/23/2021 |
cshoe |
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.
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.
:::image type="content" source="media/monitoring/azure-static-web-apps-application-insights-add.png" alt-text="Add Application Insights to Azure Static Web Apps":::
Note
Once you create the Application Insights instance, an associated application setting is created in the Azure Static Web Apps instance used to link the services together.
-
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 highlights a few locations in the portal used to inspect aspects of your application's API endpoints.
Note
For more detail on Application Insights usage, refer to Where do I see my telemetry?.
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. |
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 the Load Editor button.
-
Replace the generated query with the word
traces
. -
Select the Run button.
:::image type="content" source="media/monitoring/azure-static-web-apps-application-insights-traces.png" alt-text="View Application Insights traces":::
In some cases you may want to limit logging while still capturing details on errors and warnings 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"
}
}
}
[!div class="nextstepaction"] Setup authentication and authorization