Skip to content

Latest commit

 

History

History
131 lines (96 loc) · 6.62 KB

File metadata and controls

131 lines (96 loc) · 6.62 KB
title Use Azure Application Insights
description Configure Application Insights to capture custom logs, performance data, and availability metrics about Data API builder for analysis and troubleshooting.
author seesharprun
ms.author sidandrews
ms.reviewer jerrynixon
ms.service data-api-builder
ms.topic how-to
ms.date 06/11/2025

Use Azure Application Insights in Data API builder

:::image type="complex" source="media/how-to-use-application-insights/map.svg" border="false" alt-text="Diagram of the current location ('Monitor') in the sequence of the deployment guide."::: Diagram of the sequence of the deployment guide including these locations, in order: Overview, Plan, Prepare, Publish, Monitor, and Optimization. The 'Monitor' location is currently highlighted. :::image-end:::

Azure Application Insights is a service provided by Microsoft Azure that enables developers to monitor and gain insights into the performance and usage of their applications. The guide illustrates how to enable Application Insights for Data API builder (DAB). With Application Insights, you can track application availability, response times, performance metrics, user behavior, and other useful metrics.

Prerequisites

Warning

Application Insights for Data API builder isn't supported when hosting Data API builder in Azure App Service web apps.

  • A running solution using Data API builder

Update configuration file

First, you should add an application-insights section to your existing configuration file. This section includes the credentials necessary to connect DAB to Application Insights.

  1. Locate and open the existing configuration file for your DAB solution.

  2. In the runtime section, of the configuration file, add a telemetry section with the following properties.

    Description
    enabled Enables or disables application insights
    connection-string Connection string for Application Insights instance
    {
        "runtime": {
        ...
        "telemetry": {
            "application-insights": {
            "enabled": true,
            "connection-string": "@env('app-insights-connection-string')"
            }
        },
        ...
        }
    }

    [!TIP] Alternatively, you can use the DAB CLI to add telemetry:

    dab add-telemetry --app-insights-enabled true --app-insights-conn-string "@env('app-insights-connection-string')"
    

    [!NOTE] This sample assumes that your host has an environment variable named app-insights-connection-string with the connection string. For more information on retrieving the connection string, see Azure Monitor connection strings.

  3. Save the configuration file and redeploy your solution.

Review metrics

When you enable Application Insights in your application, it starts sending data to the Application Insights service immediately.

  1. Navigate to the Application Insights resource in the Azure portal (https://portal.azure.com).

  2. Review the following types of data captured by Application Insights about your DAB solution.

    Description
    Request telemetry Information about each incoming request to DAB, such as the URL, response time, and status code
    Trace telemetry Logs generated by DAB
    Exception telemetry Information about any exceptions or errors that occur in DAB
    Performance counters Metrics related to the performance of DAB, such as CPU usage, memory usage, and network traffic

    [!NOTE] The logs that are sent to Application Insights are same as the logs printed by Data API builder in the console.

  3. Navigate to the Logs section of the Application Insights page. Review the logs using this query.

    traces
    | order by timestamp
  4. Review the results of the query. The LogLevel is mapped to severity levels using this table.

    LogLevel Severity Level Severity Level Value
    Trace Verbose 0
    Debug Verbose 0
    Information Information 1
    Warning Warning 2
    Error Error 3
    Critical Critical 4

    [!TIP] Set the current log level using the --LogLevel option for the DAB command-line interface (CLI). Otherwise, the host mode in the config file determines the minimum loglevel. If the host mode is set to Production, the minimum log level is Error. For the Development host mode, the minimum log level is Debug.

  5. Navigate to the Live Metrics page.

    :::image type="content" source="media/how-to-use-application-insights/live-metrics.png" lightbox="media/how-to-use-application-insights/live-metrics.png" alt-text="Screenshot of the live metrics page for Data API builder data in Application Insights.":::

  6. Check the Application Requests using this query.

    requests
    | order by timestamp

    :::image type="content" source="media/how-to-use-application-insights/requests-results.png" lightbox="media/how-to-use-application-insights/requests-results.png" alt-text="Screenshot of the results of a query for Data API builder application requests in Application Insights.":::

  7. Enumerate exceptions using the Application Exceptions page.

    exceptions
    | order by timestamp

    :::image type="content" source="media/how-to-use-application-insights/exceptions-results.png" lightbox="media/how-to-use-application-insights/exceptions-results.png" alt-text="Screenshot of the results of a query for Data API builder exceptions in Application Insights.":::

Next step

[!div class="nextstepaction"] Configuration best practices