Edit

Share via


Use Azure Application Insights in Data API builder

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.

Azure Application Insights is a monitoring service that captures telemetry such as request details, performance counters, logs, and exceptions. Integrating it with Data API builder (DAB) helps you diagnose issues and monitor runtime behavior in production.

Warning Application Insights isn't supported when DAB is hosted using Azure App Service web apps.

Configuration

To configure Application Insights in your DAB config:

CLI example

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

JSON example

"runtime": {
  ...
  "telemetry": {
    "application-insights": {
      "enabled": true,
      "connection-string": "@env('app-insights-connection-string')"
    }
  }
  ...
}

This assumes app-insights-connection-string is set as an environment variable. You can use an .env file to define it.

What gets captured

Type Description
Request telemetry URL, status code, response time
Trace telemetry Console logs from DAB
Exception telemetry Errors and stack traces
Performance counters CPU, memory, network metrics

View in Azure

  1. Go to your Application Insights resource in the Azure portal: https://portal.azure.com
  2. Review logs using this query:
traces
| order by timestamp

LogLevel mapping:

LogLevel Severity Value
Trace Verbose 0
Debug Verbose 0
Information Information 1
Warning Warning 2
Error Error 3
Critical Critical 4
  1. Check Live Metrics

Screenshot of the live metrics page for Data API builder data in Application Insights.

  1. Run this query for requests:
requests
| order by timestamp

Screenshot of the results of a query for Data API builder application requests in Application Insights.

  1. Run this query for exceptions:
exceptions
| order by timestamp

Screenshot of the results of a query for Data API builder exceptions in Application Insights.