APM Tips

KQL · availability

Availability results by test and location

Success rate, run count and p95 duration for each availability test at each test location over the last 24 hours, worst first.

Updated

availabilityResults availability

let lookback = 24h;
availabilityResults
| where timestamp > ago(lookback)
| summarize
    runs = sum(itemCount),
    failed = sumif(itemCount, tostring(success) in~ ("false", "0")),
    p95_ms = percentilew(duration, itemCount, 95)
    by name, location
| extend availability_pct = round(100.0 * (runs - failed) / runs, 2)
| order by availability_pct asc, failed desc

Returns: One row per availability test and test location with the number of runs, the failed runs, the availability percentage and the p95 test duration in milliseconds, worst first.

Pitfalls

  • One location failing while the others pass usually means a network path problem near that location, not an outage. Microsoft recommends at least five locations for this reason.
  • With retries on, a run is reported as failed only after three successive attempts fail at that location, so failed counts are confirmed failures, not blips.
  • The classic schema types success as a string. The filter accepts both false and 0, so it works whichever form your results carry.
  • Custom availability tests sent from your own code land in the same table, with whatever name and location your code gave them.

How it works

Availability tests call your app from Microsoft’s test locations around the world on a schedule and record each run in availabilityResults. The portal’s availability chart summarises them; this query gives you the numbers behind it, per test and per location, so you can tell a real outage from one unhappy region.

Line by line

  • let lookback = 24h; sets the window. For an SLA report, use 30d.
  • runs = sum(itemCount) counts test runs. Weighting by itemCount costs nothing and keeps the query consistent with the rest of the library.
  • failed = sumif(itemCount, tostring(success) in~ ("false", "0")) counts failed runs. in~ compares without case, and accepting both spellings makes the filter independent of how success was written.
  • p95_ms = percentilew(duration, itemCount, 95) is how long the slowest runs took. The data model describes duration as the time the test took to execute.
  • by name, location gives one row per test per location.
  • availability_pct is the share of runs that passed; order by availability_pct asc, failed desc puts the worst first.

Reading the result

A test failing everywhere is an outage, or a broken test: check whether the URL, the expected status code or the content match changed. A test failing in one or two locations while the rest pass is usually the network between that location and you. Microsoft’s guidance is to run from at least five locations and to alert when a number of them fail together, with the alert location threshold set to the number of test locations minus two; a single-location failure shouldn’t page anyone.

A rising p95 with no failures is an early warning: the app is getting slower for everyone, and the test will start timing out at its limit. Compare with the request duration chart for the same window.

For the failed runs themselves, with their messages, see availability failures with messages. The certificate expiration and availability tests guide covers setting the tests up, including the certificate checks of standard tests.

Variations

  • Per test only: drop location from the by clause for one row per test.
  • Trend: group by bin(timestamp, 1h), name, chart availability_pct and add | render timechart.
  • Workspace tables: use AppAvailabilityResults, TimeGenerated, Name, Location, Success, DurationMs and ItemCount.

Sources, checked

  1. Application Insights availability testslearn.microsoft.com · checked
  2. Application Insights telemetry data model (availability success and duration)learn.microsoft.com · checked
  3. The case-insensitive in~ string operator (Kusto)learn.microsoft.com · checked
  4. sumif() (Kusto)learn.microsoft.com · checked
  5. Migrate an Application Insights classic resource to a workspace-based resource (table schemas)learn.microsoft.com · checked