Muokkaa

Jaa


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

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

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

  1. Select Logs under Monitoring.

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

  3. Select Load Editor.

  4. Replace the generated query with the word traces.

  5. Select Run.

View Application Insights traces

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

Next steps