Build AWS X-Ray sampling rules for controlling trace collection rates.
Last verified: May 2026
Build X-Ray sampling rule configs to control tracing rates per service, method, and URL path.
Required Fields
SamplingRule.RuleNameSamplingRule.PrioritySamplingRule.FixedRateSamplingRule.ReservoirSizeSamplingRule.ServiceNameSamplingRule.URLPathOutput will appear here...AWS X-Ray sampling rules control which requests are traced, allowing you to balance observability coverage with cost. Without custom rules, X-Ray applies a default rule that traces the first request each second and 5% of additional requests. Custom sampling rules let you set different rates for different services, URLs, HTTP methods, or other attributes. The X-Ray Sampling Rule Builder helps you define rules with proper priority ordering, reservoir sizes (guaranteed traces per second), and fixed rates (percentage of additional requests to sample).
Your team's X-Ray bill hit $400/month (80M traces from 1.6B requests at 5% default sampling). The builder helps redesign sampling: priority 1 rule traces 100% of /api/payments/* (low volume, high value); priority 100 traces 1% of /api/* (medium volume, batch debugging); priority 1000 traces 0.1% of /healthz (high volume, rarely useful); default 5% rule for everything else. New monthly cost: $30. Visibility into payment issues actually IMPROVES because you have 100% coverage on those paths.
X-Ray costs $5 per million traces recorded. The default 5% sampling rate looks low but adds up fast — 100M requests/month × 5% = 5M traces = $25/month. For high-volume services, custom sampling can drop costs 10x while maintaining the visibility you actually need (sample errors at 100%, success at 1%).
Always sample 100% of payment/auth/critical paths. The cost is negligible (these endpoints have low volume) and the debug value is enormous when something goes wrong. Use a high-priority rule with `URLPath: /api/payments/*` and a fixed rate of 1.0.
Reservoir size of 1 with fixed rate 0 is the 'always trace at least N per second' pattern. Useful for low-traffic endpoints where 5% sampling means most days have 0 traces — set reservoir 1 to guarantee at least one trace/second/endpoint for analysis.
The builder generates X-Ray sampling rules with: rule name, priority (1-9999), reservoir size (guaranteed traces/sec), fixed rate (0.0-1.0, percentage above reservoir), and matching criteria (service name + service type + HTTP method + URL path + resource ARN + host, all supporting wildcards). Output is generated as aws xray create-sampling-rule commands and Terraform aws_xray_sampling_rule resources.
Was this tool helpful?
Disclaimer: This tool runs entirely in your browser. No data is sent to our servers. Always verify outputs before using them in production. AWS, Azure, and GCP are trademarks of their respective owners.