Skip to content

Update AI Gateway monitoring to use the current OpenTelemetry configuration #9

Open

Description

Problem

The sample currently configures telemetryExporters with kind: applicationInsights and an Application Insights connection string. The current AI Gateway monitoring experience expects the native OTLP/OpenTelemetry configuration, so the portal does not reliably recognize this legacy exporter as monitoring-enabled.

Missing configuration

  • Register the Microsoft.Monitor resource provider.
  • Set AzureMonitorWorkspaceIngestionMode: Enabled on the workspace-based Application Insights resource.
  • Wait for Application Insights to generate its managed DCR/DCE and OTLP endpoints.
  • Configure the exporter with kind: OpenTelemetry, the Application Insights resource ID, metrics/logs/traces OTLP endpoints, and managed-identity audience https://monitor.azure.com.
  • Assign the AI Gateway system-assigned identity the Monitoring Metrics Publisher role (3913510d-42f4-4e42-8a64-420c390055eb) at the generated DCR scope.
  • Account for the deny assignment on the generated managed resource group: a nested ARM/Bicep role assignment is blocked, while a direct role-assignment PUT from an azd post-provision hook works.
  • Document that exporter kind is immutable, requiring delete/recreate when migrating an existing legacy exporter.

Current preview behavior

The service currently persists metrics and logs endpoints but may omit a supplied tracesEndpoint from exporter GET responses. Metrics and logs are sufficient for the portal dashboard eligibility check.

Activity

  1. paulyuk commented on Oct 25, 2026

    @paulyuk
    Member

    @copilot Please implement this on top of current main (which uses the standalone Microsoft.ApiManagement/aigateways@2025-09-01-preview resource provider from #23):

    1. Bicep (infra/ai-gateway/main.bicep & infra/main.bicep):

      • Enable AzureMonitorWorkspaceIngestionMode: 'Enabled' on gatewayAppInsights (Microsoft.Insights/components@2020-02-02) with #disable-next-line BCP037 documented.
      • Remove the inline legacy kind: 'applicationInsights' gatewayTelemetryExporter resource from infra/ai-gateway/main.bicep (since OTLP DCR/DCE endpoints and managed resource group role assignments must be configured postprovision).
      • Output AI_GATEWAY_APP_INSIGHTS_ID, AI_GATEWAY_LOG_ANALYTICS_WORKSPACE_ID, and AI_GATEWAY_PRINCIPAL_ID (from aiGateway.identity.principalId) so the postprovision script can configure the OTLP exporter.
    2. Postprovision hooks (infra/scripts/configure-ai-gateway.sh & infra/scripts/configure-ai-gateway.ps1):

      • When ENABLE_MONITORING is enabled, register Microsoft.Monitor if not already registered, poll gatewayAppInsights until its managed DCR/DCE and OTLP endpoints (IngestionEndpoint, MetricsIngestionEndpoint, LogsIngestionEndpoint, TracesIngestionEndpoint, DefaultDataCollectionRuleResourceId) are populated.
      • Assign Monitoring Metrics Publisher (3913510d-42f4-4e42-8a64-420c390055eb) to the AI Gateway system-assigned principal ID at the generated DCR scope via direct REST/CLI PUT.
      • If an existing telemetryExporters/applicationInsights resource has kind != "OpenTelemetry", delete it first (since kind is immutable), then PUT Microsoft.ApiManagement/aigateways/{gatewayName}/telemetryExporters/applicationInsights?api-version=2025-09-01-preview with kind: "OpenTelemetry", the Application Insights resource ID, OTLP endpoints, and managed-identity authentication (audience: "https://monitor.azure.com").
    3. Tests & docs:

      • Update tests/test-ai-gateway-model-registration.sh, IMPLEMENTATION_NOTES.md, and infra/ai-gateway/README.md to reflect the native OpenTelemetry exporter setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions