Log Sampling Rate Calculator
Calculate a log sampling rate that fits a daily storage target while reserving critical records and accounting for bursts and index overhead.| Measure | Value | Planning meaning | Copy |
|---|---|---|---|
| {{ row.label }} | {{ row.value }} | {{ row.note }} |
| Policy lever | Setting | Evidence | Operator action | Copy |
|---|---|---|---|---|
| {{ row.lever }} | {{ row.setting }} | {{ row.evidence }} | {{ row.action }} |
Introduction
Logging systems often receive far more routine events than a storage budget can retain. Request successes, health checks, debug messages, retries, and repeated application notices may dominate daily volume even though investigations depend on a much smaller set of errors, security records, audit events, or unusual traces.
Sampling reduces a chosen portion of that stream by keeping each eligible event with a probability. A 10% sampling rate means roughly one eligible event in ten is expected to remain over a large population. It does not promise one event from every block of ten, and it can miss a rare event entirely. Records that must be complete therefore need an always-keep rule before sampling is applied.
| Method | Useful when | Main risk |
|---|---|---|
| Filter known noise | A category has little diagnostic value | A broad rule may discard an unexpected clue |
| Probabilistic sampling | Routine events need a representative baseline | Low-frequency events may disappear |
| Keep selected classes in full | Audit, security, billing, or critical errors require coverage | The protected share may consume the whole budget |
| Shorten retention or reduce indexing | Recent search matters more than long history | Older investigations or rich queries become harder |
Daily volume depends on more than events per second. Average event size, traffic bursts, enrichment fields, indexing overhead, and the time basis of the rate all change the byte total. Measurements should come from a representative pre-sampling counter and a realistic encoded event size, not from a quiet interval or an uncompressed message sample.
A storage-fitting rate is a capacity plan rather than a complete observability policy. It can show how much of the sampleable stream fits after protected logs are reserved. It cannot decide which event classes are safe to sample, preserve related requests together, or guarantee enough evidence for incident response and compliance.
How to Use This Tool:
Measure the unsampled stream first, then reserve logs that must remain complete before solving the eligible sampling rate.
- Enter Incoming log rate with the correct per-second, per-minute, per-hour, or per-day basis.
- Enter the average encoded event size and the target retained volume per day. Keep the binary units consistent with the storage quote.
- Set Full-fidelity reserve to the share that bypasses sampling, then add a burst multiplier and storage overhead when the measured average understates peak or indexed volume.
- Read Sampleable keep rate, Overall keep rate, and the one-in-N guide together. A budget conflict means the protected share alone exceeds the target.
- Translate the percentage into the actual logging system and validate retained bytes over a representative day before treating the target as stable.
Interpreting Results:
Sampleable keep rate applies only to logs outside the protected reserve. Overall keep rate includes both protected and sampled events, so it will be higher whenever some records bypass sampling. The retained and dropped volume estimates describe the modeled day after burst and overhead adjustments.
A low percentage is not automatically wrong, but it raises the chance that uncommon eligible events will be absent. Protect critical classes explicitly, and check whether related records require consistent sampling by request, trace, user, or another stable key.
Technical Details:
All rates are converted to events per second, sizes to bytes per event, and target capacity to bytes per day. The burst multiplier increases the modeled event rate, while overhead increases bytes after event count and average size are combined. Binary storage factors are used: 1 KiB is 1,024 bytes, 1 MiB is 1,024² bytes, and 1 GiB is 1,024³ bytes.
Formula Core
The protected share is reserved first. Only the remaining bytes are reduced by the solved sampling probability.
| Symbol | Meaning | Unit |
|---|---|---|
| q | Incoming events per second after the burst multiplier | events/second |
| b | Average event size | bytes/event |
| o, p | Storage overhead and protected keep share | percent |
| B, P, S | Raw, protected, and sampleable daily bytes | bytes/day |
| K | Target retained capacity | bytes/day |
| r, R | Eligible-event sampling probability and retained daily bytes | ratio; bytes/day |
When raw volume already fits, r is capped at 1. When protected bytes exceed the target, the rate is capped at 0 and the result reports a budget conflict because sampling cannot remove protected records. One-in-N is the reciprocal of r whenever the rate is above zero. Full precision is kept through the calculation; the display setting rounds only visible values.
Rule Core
| Condition | Status |
|---|---|
| Protected bytes exceed the target | Budget conflict |
| Sampleable keep rate is at least 99.999% | Full fidelity fits |
| Sampleable keep rate is below 1% | Sparse baseline |
| Sampleable keep rate is at least 1% but below 10% | Tight budget |
| All other valid rates | Sampling planned |
Accuracy Notes:
Expected volume is only as sound as the measured rate and size distribution. Large stack traces, payload fragments, enrichment fields, multiline events, and index replicas can make an average message sample too small.
- Measure before sampling and across a period that includes normal peaks.
- Keep compliance, security, billing, and incident-critical classes outside probabilistic sampling when completeness matters.
- Recalculate after parser, enrichment, indexing, routing, or retention policy changes.
Worked Examples:
A stream that needs a half-rate sample
One 1,024-byte event per second produces 86,400 events and 84.375 MiB per day with no burst or overhead. A 42.1875 MiB target and no protected reserve yields a 50% sampleable keep rate. The expected result is 0.5 retained events per second, 42.1875 MiB retained per day, and a one-in-two guide.
References:
- Processors, OpenTelemetry documentation.
- Probabilistic Sampling Processor, OpenTelemetry Collector Contrib documentation.
- Log exclusion resources, Google Cloud Logging documentation.