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.

  1. Open the Static Web Apps instance in the Azure portal.

  2. Select Application Insights from the menu.

  3. Select Yes next to Enable Application Insights.

  4. Select Save.

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.

Access data

  1. From the Overview window in your static web app, select the link next to the Resource group.

  2. 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.

Traces

Using the following steps to view traces in your application.

  1. Select Logs under Monitoring.

  2. Hover your mouse over any card in the Queries window.

  3. Select the Load Editor button.

  4. Replace the generated query with the word traces.

  5. Select the Run button.

View Application Insights traces

Limit logging

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"
        }
    }
}

Next steps