APM Tips

KQL · operations

Cloud role instances and versions seen per role

For each service, the instances and application versions that sent requests in the last 24 hours, with traffic per version and when each was last seen.

Updated

requests operations

let lookback = 24h;
requests
| where timestamp > ago(lookback)
| summarize
    requests = sum(itemCount),
    instances = dcount(cloud_RoleInstance),
    instance_names = make_set(cloud_RoleInstance, 20),
    first_seen = min(timestamp),
    last_seen = max(timestamp)
    by cloud_RoleName, application_Version
| order by cloud_RoleName asc, last_seen desc

Returns: One row per service and application version with its sampling-adjusted request count, the number and names of instances that served it, and when it was first and last seen in the window.

Pitfalls

  • application_Version is empty unless your build or SDK sets it. An empty version column means nobody set it, not that the version is unknown to the app.
  • Two versions with recent last_seen times for the same role mean both are serving traffic: a rollout in progress, a deployment slot taking traffic, or an instance that missed the update.
  • Instance names on platforms that replace instances (containers, autoscaled hosts) change often; a long instance list is normal there.
  • make_set() shows at most the number of names you ask for. Raise the 20 for large fleets, or rely on the instances count.

How it works

“Which version is running where?” sounds like a question for the deployment tool, but the deployment tool tells you what you shipped, not what is answering requests. This query reads the answer from the telemetry itself: for each service, which versions served traffic, on how many instances, and until when.

Line by line

  • let lookback = 24h; sets the window. Shorten it to 1h during a rollout to see the current state.
  • requests = sum(itemCount) counts the traffic each version served, sampling-adjusted.
  • instances = dcount(cloud_RoleInstance) counts distinct instances, and make_set(cloud_RoleInstance, 20) lists up to 20 of their names. Microsoft’s Application Map documentation describes the role instance as the way to tell whether an issue affects all servers of a component or only some.
  • first_seen and last_seen bracket each version in the window. A version whose last_seen is an hour ago has been replaced; one whose first_seen is ten minutes ago has just arrived.
  • by cloud_RoleName, application_Version gives one row per service and version.
  • order by cloud_RoleName asc, last_seen desc groups rows by service, newest version first.

When to use it

During and after a rollout, to confirm every instance picked up the new version. During an incident, to check whether the failing requests all come from one version: add failed = sumif(itemCount, tostring(success) =~ "false") to the summarize and compare the versions side by side. And as a sanity check of your telemetry setup: a role with no version, or one instance named after a build agent, tells you something is set wrong.

The version only appears if something sets it. The version and build information guide shows how to set application_Version in the classic SDK and with OpenTelemetry, and the correlation and Application Map guide covers role names and instances.

Variations

  • Per instance health: group by cloud_RoleName, cloud_RoleInstance and add a weighted p95 of duration to find one slow machine; performance counters then shows its CPU and memory.
  • All telemetry, not just requests: use union requests, dependencies, traces to include services that only send logs or dependency calls.
  • Workspace tables: use AppRequests, TimeGenerated, AppRoleName, AppRoleInstance, AppVersion and ItemCount.

Sources, checked

  1. Application map in Application Insights (cloud role names and instances)learn.microsoft.com · checked
  2. Application Insights telemetry data model (application version)learn.microsoft.com · checked
  3. make_set() (Kusto)learn.microsoft.com · checked
  4. dcount() (Kusto)learn.microsoft.com · checked
  5. Migrate an Application Insights classic resource to a workspace-based resource (table schemas)learn.microsoft.com · checked