Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Application Insights includes a custom sampler and integrates with OpenTelemetry to reduce telemetry volume, lower costs, and retain the diagnostic data you care about.
Important
For information on sampling when using the Application Insights Classic API Software Development Kits (SDKs), see Classic API Sampling.
Prerequisites
Before you continue, make sure you have:
- A basic understanding of data collection methods
- A basic understanding of OpenTelemetry sampling concepts
- An application instrumented with OpenTelemetry
Why sampling matters
Sampling is essential for applications generating large amounts of telemetry.
Without sampling, excessive data ingestion can:
- Increase storage and processing costs
- Cause Application Insights to throttle telemetry
Effective sampling keeps enough data for meaningful diagnostics while controlling cost.
Sampling is not enabled by default in Application Insights OpenTelemetry distros. You must explicitly enable and configure sampling to manage your telemetry volume.
Note
If you're seeing unexpected charges or high costs in Application Insights, this guide can help. It covers common causes like high telemetry volume, data ingestion spikes, and misconfigured sampling. It's especially useful if you're troubleshooting issues related to cost spikes, telemetry volume, sampling not working, data caps, high ingestion, or unexpected billing. To get started, see Troubleshoot high data ingestion in Application Insights.
Application Insights custom sampler
The Azure Monitor OpenTelemetry-based distro includes a custom sampler.
- Live Metrics and the Application Insights classic API SDKs require this sampler for compatibility.
- The sampler is disabled by default. You must explicitly enable and configure sampling to use the sampler.
- It uses a fixed-rate algorithm. For example, a rate of 10% sends about 10% of traces to Azure Monitor.
- The Azure Monitor Application Insights service relies on this sampler to show you complete traces and avoid broken ones.
Benefits
- Consistent sampling decisions during interoperability with applications using the Application Insights Classic API Software Development Kits (SDKs).
- Full compatibility with Live Metrics because the sampler is aware of Live Metrics requirements.
To configure the sampling percentage, refer to Enable Sampling in Application Insights with OpenTelemetry.
For more detailed information and sampling edge cases, see Frequently Asked Questions.
Ingestion sampling (not recommended)
Ingestion sampling is a fallback when source-level control isn't possible. It drops data at the Azure Monitor ingestion point and offers no control over which traces and spans are retained. This increases the likelihood of encountering broken traces.
Scenarios where it's the only viable or most practical option include:
- You can't modify the application source code.
- You need to reduce telemetry volume immediately without redeploying applications.
- You receive telemetry from multiple sources with inconsistent or unknown sampling configurations.
To configure ingestion sampling:
- Go to Application Insights > Usage and estimated costs.
- Select Data Sampling.
- Choose the percentage of data to retain.
Set a daily cap
Set a daily cap to prevent unexpected costs. This limit stops telemetry ingestion when it reaches the threshold.
Use this cap as a last-resort control, not a replacement for sampling. A sudden increase in data volume can trigger the cap, creating a gap in telemetry until it resets the next day.
To configure the cap, see Set a daily cap for Azure Monitor.
Next steps
- To review frequently asked questions (FAQ), see OpenTelemetry sampling FAQ
- OpenTelemetry Sampling Concepts.
- Enable Sampling in Application Insights
- Application Insights Overview
- Troubleshoot high data ingestion in Application Insights