APM Tips

Glossary

itemCount

The column on every sampled Application Insights row that records how many original telemetry items the row stands for, so totals stay right after sampling.

Updated

When an SDK or distro samples, it keeps some items, drops the rest, and writes on each kept item how many it represents. With sampling at 25 percent, every kept request carries an itemCount of 4. Without sampling it is 1.

That is why counting rows gives the wrong answer on sampled data. Count with sum(itemCount) instead of count(), and weight percentiles with it too. The same column shows the rate that was in effect: Microsoft’s sampling documentation gives the retained percentage as 100 / avg(itemCount).

requests
| where timestamp > ago(1d)
| summarize rows = count(), requests = sum(itemCount), retained_percent = 100.0 / avg(itemCount)

If that returns 25,000 rows and 100,000 requests, a quarter of the requests were kept, and every chart built on count() was four times too low.

Some telemetry is never sampled: sessions, metrics (custom metrics included) and performance counters. The classic customMetrics and performanceCounters tables have no itemCount column, so plain aggregates are right there. In a Log Analytics workspace the column is called ItemCount, on AppRequests, AppDependencies and the other sampled App* tables.

Sources, checked

  1. Sampling in Application Insights (Classic API)learn.microsoft.com · checked
  2. Migrate to workspace-based Application Insights resources (table and column names)learn.microsoft.com · checked

All glossary terms