You are monitoring an Azure Web App using Application Insights. You need to write an optimized Kusto Query Language (KQL) query to analyze successful dependency calls to an external API named 'PaymentGateway' over the last 24 hours. The query must return the average duration of these calls grouped by the custom dimension 'TenantId'. Which KQL query should you run?
- dependencies
| where timestamp > ago(24h)
| where name == "PaymentGateway" and success == true
| extend Tenant = tostring(customDimensions.TenantId)
| summarize AvgDuration = avg(duration) by TenantCevap - Bdependencies
| where name == "PaymentGateway" and success == true
| extend Tenant = tostring(customDimensions.TenantId)
| summarize AvgDuration = avg(duration) by Tenant - Cdependencies
| where timestamp > ago(24h)
| where name == "PaymentGateway" and success == true
| extend Tenant = tostring(customDimensions.tenantid)
| summarize AvgDuration = avg(duration) by Tenant - Ddependencies
| where timestamp > ago(24h)
| where name == "PaymentGateway" and success == true
| where connectionString == "InstrumentationKey=00000000-0000-0000-0000-000000000000"
| extend Tenant = tostring(customDimensions.TenantId)
| summarize AvgDuration = avg(duration) by Tenant
Cevap
The KQL query that filters by timestamp > ago(24h), checks for successful 'PaymentGateway' calls, extracts the case-sensitive customDimensions.TenantId, and summarizes the average duration by Tenant.
The correct query begins with a time filter ('timestamp > ago(24h)') to ensure optimal query execution. It then filters for successful dependency calls specifically named 'PaymentGateway'. Next, it correctly extracts the case-sensitive 'TenantId' from the 'customDimensions' dynamic field using the 'tostring()' function and assigns it to an alias. Finally, it uses the 'summarize' operator with the 'avg(duration)' aggregation function to calculate the average duration grouped by the tenant alias.
Adım Adım Çözüm
Anahtar Kavram
Querying and filtering custom dimensions within Application Insights telemetry tables using KQL while maintaining performance through time-range filters.
Tahmini Süre:1m 30s