name: query-app-insights description: Query Azure Application Insights telemetry data for command usage, extension activity, and performance metrics disable-model-invocation: true
Query App Insights
Query Azure Application Insights telemetry to answer questions about command usage, extension activity, performance.
Prerequisites
APP_INSIGHTS_API_KEYenv varAPP_INSIGHTS_CLIENT_IDenv var
Workflow
- Validate credentials - check env vars exist
- Test API -
tsx scripts/queryAppInsights.ts "customEvents | take 1" - Interpret question - identify commands, extensions, time ranges, metrics
- Find executor name - if checking a command, find its executor name (see references)
- Build KQL query - use executor names, not command IDs
- Execute -
tsx scripts/queryAppInsights.ts "<kql-query>" - Answer - interpret results, format clearly
Key Points
- Telemetry uses executor names, not command IDs
- Event pattern: ends with
/commandExecution(Legacy/v2) or stored independenciestable (OTEL/v3) - Tables:
customEvents(Legacy),dependencies(OTEL Spans),requests(Root Spans) - OTEL Properties:
name(Span name),cloud_RoleName(Extension name),operation_Id(Trace ID),operation_ParentId(Parent Span ID) - OTEL Root Filter:
where operation_ParentId == operation_Id(Finds top-level spans in v3) - Measurements:
customMeasurements.executionTime(ms for Legacy) orduration(ms for OTEL)
References
references/command-id-vs-executor.md- Finding executor names, shared executors, commands without telemetryreferences/query-patterns.md- Common KQL patternsreferences/script.md- Script implementation details