Soru

Zorluk: OrtaQuery and Analyze Application Insights Telemetry

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?

  1. dependencies
    | where timestamp > ago(24h)
    | where name == "PaymentGateway" and success == true
    | extend Tenant = tostring(customDimensions.TenantId)
    | summarize AvgDuration = avg(duration) by Tenant
    Cevap
  2. B
    dependencies
    | where name == "PaymentGateway" and success == true
    | extend Tenant = tostring(customDimensions.TenantId)
    | summarize AvgDuration = avg(duration) by Tenant
  3. C
    dependencies
    | where timestamp > ago(24h)
    | where name == "PaymentGateway" and success == true
    | extend Tenant = tostring(customDimensions.tenantid)
    | summarize AvgDuration = avg(duration) by Tenant
  4. D
    dependencies
    | 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

1
Apply a time-range filter using the timestamp column.
Limits the query scan to telemetry from the last 24 hours, optimizing query performance.
Omitting a time range forces KQL to scan the entire historical telemetry dataset, which is inefficient and may exceed query limits.
2
Filter by the dependency name and success status.
Isolates records where the dependency name is 'PaymentGateway' and success is true.
We are specifically interested in successful calls to this particular external gateway.
3
Access and cast the custom dimension TenantId.
Extracts the dynamic property 'TenantId' from customDimensions and casts it to a string using tostring().
Custom dimensions are stored as dynamic JSON objects and are case-sensitive. The property name 'TenantId' must match the casing used when the telemetry was logged.
4
Summarize the average duration grouped by the tenant.
Outputs a table containing each unique Tenant and its average dependency call duration.
The 'summarize' operator with the 'avg()' aggregation function calculates the average duration grouped by the 'Tenant' key.

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
Bu soruyu puanla