| 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 |
:::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.
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
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.
-
Locate and open the existing configuration file for your DAB solution.
-
In the
runtimesection, of the configuration file, add atelemetrysection with the following properties.Description enabledEnables or disables application insights connection-stringConnection 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-stringwith the connection string. For more information on retrieving the connection string, see Azure Monitor connection strings. -
Save the configuration file and redeploy your solution.
When you enable Application Insights in your application, it starts sending data to the Application Insights service immediately.
-
Navigate to the Application Insights resource in the Azure portal (https://portal.azure.com).
-
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.
-
Navigate to the Logs section of the Application Insights page. Review the logs using this query.
traces | order by timestamp
-
Review the results of the query. The
LogLevelis 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
--LogLeveloption 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 toProduction, the minimum log level isError. For theDevelopmenthost mode, the minimum log level isDebug. -
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.":::
-
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.":::
-
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.":::
[!div class="nextstepaction"] Configuration best practices