What Is Batching in the OpenTelemetry Collector?

What Is Batching in the OpenTelemetry Collector?

A friendly, ground-up guide to the simple idea of sending telemetry in groups instead of one piece at a time: what the batch processor does, how it decides when to send, how to tune it, and what can go wrong.

Imagine a small village with a bus stop. If the driver left the stop every time one passenger arrived, the bus would make hundreds of trips each day, burning fuel to carry one person at a time. Instead, the bus waits. It leaves when it is full, or when the timetable says it is time to go, whichever comes first. Fewer trips carry far more people, and everyone still reaches the city on time.

Batching in the OpenTelemetry Collector works exactly like that bus. The Collector receives a huge stream of tiny pieces of telemetry, such as spans, metrics and logs. Instead of forwarding each piece alone, it collects them into groups, called batches, and sends each group together. In this guide, we will learn what batching is, how the Collector decides when to send, and how to set it up wisely, using simple words and everyday examples.

200 ms
A common default wait time before a partly full batch is sent
8,192
A common default number of items that triggers a send
Last
Where the batch processor usually sits in the processor order

1The Problem: Sending Tiny Pieces Is Wasteful

Before learning the tool, let us feel the problem it solves.

A quick reminder of the Collector

The OpenTelemetry Collector is a standalone program that receives telemetry, which is information that software sends out about itself, such as traces, metrics and logs. It can clean and reshape the data, and then forward it to storage systems, called backends. Inside the Collector, data flows through a pipeline: receivers bring data in, processors work on it, and exporters send it out.

What happens if we send every piece alone?

Think about a busy online store. It may create tens of thousands of spans every second. If the Collector sent each span to the backend in its own network request, several bad things would happen.

  • Too many trips. Every network request has a fixed cost: opening a connection, adding headers, waiting for a reply. Doing this thousands of times a second wastes huge effort.
  • Poor compression. Compression works by finding repeating patterns. A single tiny message has very few patterns, but a large group of similar messages compresses very well.
  • Overloaded backends. Many storage systems prefer fewer, larger writes. A flood of tiny requests can slow them down, trigger rate limits, or raise your bill.
  • Higher CPU use. Each send needs work, such as encoding the data and managing connections. Doing it per item multiplies that cost.
Everyday Analogy

Think of a post office. If the delivery van left for every single letter, the post office would need hundreds of vans, and most would travel almost empty. Instead, letters go into bags, and a van takes a full bag at a scheduled time. Batching is the bag.

2So, What Is Batching in the Collector?

The short answer first, and then the details.

Batching in the Collector means holding incoming telemetry for a short time, grouping it into larger bundles, and then sending each bundle on together. In the Collector, this is mainly done by a processor called the batch processor. It works for all three signals: traces, metrics and logs.

The batch processor follows a very simple rule. It sends a batch when either the batch has collected enough items, or enough time has passed since the batch began, whichever happens first. This two-part rule is the heart of batching.

Send when full, or send when the clock says so. Whichever comes first.
flowchart TD
    A["Telemetry arrives from receivers"] --> B["Batch processor collects items"]
    B --> C{"Has the batch reached the target size?"}
    C -->|Yes| D["Send batch now"]
    C -->|No| E{"Has the timeout expired?"}
    E -->|Yes| D
    E -->|No| B
    D --> F["Exporter sends batch to backend"]
    
Figure 1: The two triggers that cause a batch to be sent

What counts as one item?

The batch size is counted in the natural unit of each signal. For traces, it counts spans. For logs, it counts log records. For metrics, it counts data points, which are the individual measurements, and not the number of metrics. This small detail matters when you pick a size, because one metric can contain many data points.

i
Tip

Do not confuse this with batching inside the SDK of your application. The SDK has its own batch span processor and batch log processor, which group data before sending it to the Collector. Collector batching is a second, separate round of grouping that happens later in the journey.

3Core Concepts: The Knobs You Can Turn

The batch processor has only a few settings. Understanding each one is most of the skill.

SettingWhat It ControlsPlain Meaning
timeoutThe longest time a batch may wait before being sentThe bus timetable. Even if the bus is empty, it leaves on time. A common default is 200 milliseconds.
send_batch_sizeThe number of items that triggers a sendThe bus is full and leaves. A common default is 8,192 items.
send_batch_max_sizeThe largest batch allowed to leaveA hard cap. Bigger bundles are split into pieces. By default there is no cap.
metadata_keysRequest details used to keep separate batches for different sendersSeparate buses for separate destinations, such as one per customer
metadata_cardinality_limitThe maximum number of separate batches created by metadataA safety limit on how many buses can exist at once

The most confusing pair: send size versus max size

Beginners often think send_batch_size is a strict limit. It is not. It is a trigger. It says, “once I have at least this many items, send.” But a big group of incoming data can arrive all at once, so the batch could end up larger than that number. If you want a firm upper limit, you must set send_batch_max_size. When it is set, the processor splits large bundles so that none is bigger than the limit. The max size must be equal to or larger than the send size.

Everyday Analogy

Imagine a lift with a sign: “Doors close after 8 people.” That is the trigger. But a tour group of 20 walks in together. The lift would carry all 20. If there is also a weight limit sign, “Maximum 12 people,” then the group must be split into two trips. The first sign is the send size. The second is the max size.

Why the max size matters in real life

Many receiving systems refuse messages that are too large. For example, a common default limit for a single network message in the gRPC technology is around four megabytes. If your batches grow bigger than the backend allows, the whole batch may be rejected, and you will lose data or waste retries. A sensible max size keeps each bundle within a safe range.

4Internal Working: What Happens Inside the Processor

Let us follow items as they arrive over a few moments.

sequenceDiagram
    participant R as Receiver
    participant B as Batch Processor
    participant E as Exporter
    participant K as Backend
    R->>B: 3000 spans arrive
    B->>B: Hold items and start timer
    R->>B: 6000 more spans arrive
    B->>B: Total passes 8192 so size trigger fires
    B->>E: Send batch of spans
    E->>K: One network request
    R->>B: 500 spans arrive
    B->>B: Hold items and start timer
    B->>B: Timer expires with batch still small
    B->>E: Send small batch because of timeout
    E->>K: One network request
    
Figure 2: One batch sent because it was full, and one because the timer ran out
1

Items Arrive

A receiver hands telemetry to the batch processor. The processor accepts it quickly and places it in an internal holding area.

2

The Timer Starts

When the first item enters an empty batch, a clock starts running for the timeout.

3

A Trigger Fires

Either the item count reaches the send size, or the timer reaches the timeout. Whichever happens first causes a send.

4

Optional Splitting

If a max size is set and the batch is bigger, the processor cuts it into pieces no larger than the limit.

5

Hand-Off to the Exporter

The finished batch moves to the next component, usually an exporter, which sends it over the network to a backend.

6

Flush on Shutdown

When the Collector is shutting down in an orderly way, the processor sends whatever is still waiting, so that little is lost.

A separate batcher for each pipeline

Each pipeline gets its own working copy of a processor. If you list the same batch processor in two pipelines, such as traces and logs, each pipeline has its own independent batch. They do not share items. This keeps signals from mixing.

Batching by sender with metadata

Sometimes one Collector serves several customers or teams, and you must not mix their data in one batch. The batch processor can keep separate batches for each value of chosen request details, called metadata, such as a tenant ID in an incoming request header. This is powerful, but each unique value creates its own batch in memory, which is why there is a cardinality limit to protect the Collector.

5Where Batching Sits in the Pipeline

Order matters, and batching has a favourite spot.

In a pipeline, every processor works on the output of the one before it. The batch processor is normally placed near the end, right before the exporters. The reason is simple: other processors may remove, change or reshape data. If you batch first and filter later, the batches become uneven and smaller than planned, and you have wasted effort.

flowchart LR
    R["Receiver"] --> M["Memory Limiter"]
    M --> E1["Enrichment"]
    E1 --> F["Filter and Redaction"]
    F --> S["Sampling"]
    S --> B["Batch"]
    B --> X["Exporter"]
    X --> BK["Backend"]
    
Figure 3: A common order, with the memory limiter first and batch last
1

Memory Limiter First

It protects the Collector at the door. It should see data before anything heavy happens.

2

Enrich, Filter and Redact

These change or remove data. Do them before batching so batches contain only what will be sent.

3

Sample Before Batching

Sampling removes data. There is no point packing items that will be thrown away a moment later.

4

Batch Last

Group what remains into efficient bundles for the trip out.

Everyday Analogy

Think of packing a suitcase. You first decide what to take, remove what is not needed, and wash what is dirty. Only then do you pack everything into the bag. Packing first and sorting later would be a mess. Batching is the final packing step.

!
Watch Out

A batch processor with tail sampling needs care. Tail sampling waits to see complete traces. Put the batch processor after it, never before, or the batching may scatter spans of the same trace in ways that confuse the sampling decision.

6Why Batching Helps: The Benefits in Detail

Four separate gains come from the same simple idea.

Network

Fewer Requests

One request carries thousands of items. The fixed cost of connecting and waiting for a reply is shared by all of them.

Size

Better Compression

Large groups of similar data shrink much better than tiny messages, so less data travels over the network. This can reduce transfer costs in the cloud.

Backends

Gentler on Storage

Backends often handle fewer, larger writes much better than a storm of small ones, and may charge or limit by request count.

Efficiency

Less CPU Per Item

Encoding, connection handling and retries are done once per batch, not once per item.

Stability

Smoother Traffic

Bursty input is turned into steadier output. Spikes are absorbed into larger batches instead of hammering the backend.

Cost

Lower Bills

Fewer requests, smaller transfers and lighter loads often mean a lower cost for hosting the Collector and for data transfer.

Production Example: The Request Storm

A team once ran a Collector with no batching. Their backend began to reject data because it was getting over fifty thousand small requests each minute. After adding a batch processor with default settings, the same data arrived in a few hundred requests. The rejections stopped, the Collector used less CPU, and the monthly network cost dropped noticeably.

7The Two Buffers: Batch Processor and Exporter Queue

Many beginners do not realise that data can wait in more than one place.

After the batch processor creates a batch, the next step is the exporter. Most exporters have their own sending queue, a waiting line for batches that are ready to be sent, along with retry settings that try again when the backend is briefly unavailable. So there are two places where data waits in memory.

flowchart LR
    A["Items arrive"] --> B["Buffer 1: Batch Processor groups items"]
    B --> C["Buffer 2: Exporter sending queue holds finished batches"]
    C --> D{"Backend accepted the batch?"}
    D -->|Yes| E["Done"]
    D -->|No| F["Retry with waiting time between attempts"]
    F --> C
    F --> G["Give up after the retry limit and drop the batch"]
    
Figure 4: Data waits first in the batch processor, then in the exporter queue

Buffer 1: Batch Processor

  • Purpose is to group items into efficient bundles
  • Holds data only briefly, controlled by the timeout
  • Lives in memory, so data is lost if the Collector crashes
  • Does not retry. Its job ends when it hands the batch on

Buffer 2: Exporter Queue

  • Purpose is to survive slow or briefly broken backends
  • Holds finished batches while retries happen
  • Can be in memory, or stored on disk for better survival of restarts
  • Has a size limit, and drops data if it overflows

An important honest limit

Because the batch processor accepts data and then sends it later in the background, the sender who gave it the data is usually told “received” long before the data reaches the backend. If the backend later fails for long enough that retries run out, or the Collector crashes, the sender never learns that some data was lost. This is a known trade-off of batching in a processor.

The OpenTelemetry community has been working on moving batching into the exporter’s own sending queue, which can be combined with disk-based storage and gives more honest feedback to senders. This area has been changing, so check the current Collector documentation to see which approach is recommended for your version.

i
Tip

If losing data on a crash is unacceptable for you, look at exporter queues that store data on disk, instead of relying on in-memory batching alone. Even then, no setup is perfectly lossless, so decide how much loss your business can accept.

8Tuning: Finding the Right Settings

There is no magic number. The right values depend on your traffic and your backend.

The central trade-off: speed versus efficiency

Every batching choice balances two things. Freshness means how soon data appears in your dashboards. Efficiency means how cheaply the data is moved. A short timeout and small batch give fresher data but more requests. A long timeout and big batch give fewer requests but later data.

If You ChooseYou GainYou Pay
Shorter timeoutData reaches the backend soonerMore, smaller requests and higher overhead
Longer timeoutFuller batches and fewer requestsData is delayed by up to the timeout
Smaller batch sizeLower memory use and smaller messagesMore requests and less compression benefit
Larger batch sizeFewer requests and better compressionMore memory and a risk of oversized messages
Setting a max sizeSafe, predictable message sizesSlightly more work splitting large bundles

Read the Collector’s own numbers

The batch processor reports metrics about itself. Their names begin with the word otelcol followed by processor and batch. The exact names can vary by version, but the ideas are stable, and they tell you what is happening.

  • How many batches were sent because of size, versus how many were sent because of the timeout.
  • The sizes of the batches that were sent, both in item count and, in newer versions, in bytes.
  • The number of separate metadata batches, if you use metadata keys.
flowchart TD
    S["Look at batch metrics"] --> Q1{"Are most sends caused by the timeout?"}
    Q1 -->|Yes| Q2{"Are batches much smaller than the size target?"}
    Q2 -->|Yes| A1["Traffic is low or timeout is short. Consider a longer timeout or smaller size target"]
    Q2 -->|No| A2["Settings look balanced"]
    Q1 -->|No| Q3{"Are most sends caused by the size trigger?"}
    Q3 -->|Yes| Q4{"Are batches exceeding backend message limits?"}
    Q4 -->|Yes| A3["Set or lower the max size"]
    Q4 -->|No| A4["Traffic is high and batching is efficient"]
    Q3 -->|No| A5["Check for traffic problems or missing data"]
    
Figure 5: A simple way to tune using the processor’s own metrics
Everyday Analogy

Think of the bus again. If the bus almost always leaves because of the timetable and carries only three people, either the timetable is too short or too few people ride at that hour. If the bus always fills up within seconds, you are carrying plenty of people, and the bus is being used well. The numbers on the bus tell you which case you are in.

A practical approach

1

Start With the Defaults

They are chosen to work well for many situations. Do not tune before you have real data.

2

Check Your Backend’s Limits

Find the maximum message size and request rate your backend accepts, and set a max size that stays safely below it.

3

Watch the Metrics Under Real Load

Observe how batches are triggered, and how large they are, at your busiest and quietest times.

4

Change One Setting at a Time

Adjust a single value, wait, and compare. Changing several together hides what helped.

5

Retest After Traffic Changes

A new feature or a big customer can change your traffic shape. Review the settings again when that happens.

9Batching and the Memory Limiter: A Team

Held data takes up memory, and memory is not unlimited.

Every item held in a batch uses memory. If your traffic suddenly jumps, many batches may hold a lot of data for a moment. The memory limiter processor is the Collector’s guard for this problem. It watches the Collector’s memory use, and when it gets near a limit, it starts refusing new data so the Collector does not crash. This is why it is placed before the batch processor.

Production Example: The Black Friday Spike

An online retailer’s traffic triples in a few minutes. Without protection, batches and queues would grow until the Collector ran out of memory and was restarted by the system, losing everything it held. With a memory limiter in front, the Collector politely refuses some data at the peak. Senders retry shortly after, and most data still arrives. A small delay replaces a crash.

Sizing the Collector

Add up the memory that batches could use at once, such as the batch size times the typical item size, times the number of pipelines, times any metadata batches. Then add the exporter queue. Compare it with the memory your container is allowed to use. If the numbers are close, either lower the sizes or raise the container limit.

10Batching in Different Deployment Layouts

Where you run the Collector affects how you batch.

Agent

Collector Beside the App

A small Collector on the same machine or pod. Batches are small to moderate. Short timeouts keep data fresh and memory low.

Gateway

Central Collector

A shared Collector that receives from many agents. Larger batches make sense here, since traffic is higher and the final trip to the backend is the most expensive.

Multi-Tenant

Many Customers in One Collector

Use metadata keys so each customer’s data is batched separately, and set a cardinality limit to protect memory.

Short-Lived

Serverless and Jobs

If a program ends quickly, a long batch timeout can leave data unsent. Make sure data is flushed before shutdown.

flowchart LR
    A1["App with SDK batching"] --> AG1["Agent Collector with small batches"]
    A2["App with SDK batching"] --> AG2["Agent Collector with small batches"]
    AG1 --> GW["Gateway Collector with larger batches"]
    AG2 --> GW
    GW --> BE["Backend"]
    
Figure 6: Batching happens at several layers, each with its own purpose

Notice that batching can happen three times along the way: in the application’s SDK, in the agent Collector and in the gateway Collector. Each round has a different purpose. The first makes the trip from the app efficient. The second makes the trip to the gateway efficient. The last makes the final trip to the backend efficient. Do not worry about “double batching.” It is normal, as long as the total delay stays within what you can accept.

!
Watch Out

Delays add up. If the SDK waits five seconds, the agent waits a second, and the gateway waits another few seconds, data may reach the backend ten or more seconds late. That may be fine for troubleshooting, but too slow for fast alerts. Add up the waits across all layers.

11Advantages, Disadvantages and Trade-offs

Honest accounting of what batching gives and what it costs.

Advantages

  • Efficient network use: fewer, larger requests
  • Better compression: smaller data over the wire
  • Gentler on backends: fewer writes and lower chance of rate limiting
  • Lower resource cost: less CPU and fewer connections
  • Smooths spikes: bursty traffic becomes steadier
  • Simple to set up: works well with defaults

Disadvantages

  • Adds delay: data waits up to the timeout
  • Uses memory: held data counts against limits
  • Can lose data: in-memory batches vanish if the Collector crashes
  • Hides failures from senders: acceptance happens before delivery
  • Wider blast radius: one bad record can cause a whole batch to be rejected
  • Evolving area: recommendations about where to batch have been changing

Key trade-offs

DecisionOption AOption B
Where to batchIn a processor, which is simple and widely usedIn the exporter queue, which can pair with disk storage and clearer feedback
Batch sizeLarge, for efficiencySmall, for low memory and fast delivery
TimeoutLong, for fuller batchesShort, for fresher data
DurabilityIn-memory, for speed and simplicityDisk-backed queues, for survival of restarts at some cost to speed
Multi-tenant batchingSeparate batches per tenant, for isolationOne shared batch, for lower memory use and simplicity

12Security Considerations

Batching does not change what your data says, but it does change where data sits and for how long.

Memory

Data Sits in Memory

Batches hold real telemetry in the Collector’s memory. If the machine is compromised, this data may be exposed. Limit access to Collector hosts.

Order

Redact Before You Batch

Place redaction and attribute-removal processors before batching, so that sensitive values are never held in batches at all.

Floods

Resource Exhaustion

An attacker or a bug that floods the Collector can fill memory with batches. A memory limiter and sensible sizes protect against this.

Tenants

Cardinality Abuse

If batching by metadata, a sender could invent endless metadata values and force thousands of tiny batches. Keep the cardinality limit in place.

Isolation

Keep Tenants Apart

Separate batches per tenant avoid mixing different customers’ data in one bundle sent to a backend.

Transport

Encrypt the Export Path

Use encrypted, authenticated connections from the Collector to the backend, since batches carry a lot of data in one go.

!
Watch Out

Disk-backed queues write telemetry to storage. If that data contains sensitive values, the files themselves become something to protect. Encrypt the disk, restrict access, and clean up old files.

13Monitoring, Logging and Troubleshooting

A pipeline that handles your monitoring data needs to be monitored too.

  • Trigger mix: watch the share of sends caused by size versus timeout. A sudden change shows that traffic patterns have shifted.
  • Batch sizes: track average and largest batch sizes. Very small ones waste efficiency, and very large ones risk rejection.
  • Refused data: if the memory limiter is refusing data, the Collector is under pressure.
  • Exporter failures and drops: watch for failed sends, retries, and dropped batches from full queues.
  • Queue depth: an exporter queue that is always nearly full means the backend cannot keep up.
  • Collector memory and CPU: check that these stay well below the container’s limits.
  • Received versus sent counts: compare items received with items exported. A growing gap means loss somewhere in between.
  • Collector logs: rejected-message errors from the backend often point to batches that are too large.

Common symptoms and likely causes

SymptomLikely CauseWhat to Try
Data arrives late in dashboardsTimeouts stacked across layers, or a long timeoutAdd up waits across SDK, agent and gateway, then shorten the largest
Backend rejects messages as too largeNo max size, so batches grow too bigSet a max size below the backend’s limit
Many tiny requestsTimeout firing before batches fillRaise the timeout or lower the size trigger
Collector memory keeps growingLarge batches, many pipelines, metadata batches or full queuesLower sizes, limit metadata cardinality, add a memory limiter
Data missing after a restartIn-memory batches and queues were lostConsider disk-backed queues and graceful shutdown
Batch processor seems to do nothingDefined but not listed in the pipelineAdd it to the processors list of the pipeline

14Design Patterns and Anti-Patterns

Habits worth copying and traps worth avoiding.

Good design patterns

Pattern

Protect, Process, Batch

Memory limiter first, shaping processors in the middle, batch last. A simple and reliable order.

Pattern

Cap the Message Size

Always know your backend’s message limit and set a max size beneath it.

Pattern

Layered Batching

Small batches at the edge, larger batches at the gateway, each tuned to its job.

Pattern

Two Buffers, Two Purposes

Use the batch processor for grouping and the exporter queue, optionally on disk, for resilience.

Pattern

Measure Then Tune

Use the processor’s own metrics to guide changes, one at a time.

Pattern

Graceful Shutdown

Give the Collector time to flush batches when it is stopped or replaced, for example during a rolling update.

Anti-patterns

ANTI-PATTERN 01Avoid
The Mistake

Leaving the batch processor out entirely on a high-traffic pipeline.

Why It Hurts

The backend sees a flood of tiny requests, and costs, CPU use and rejection rates all rise.

Better Approach

Add a batch processor, or exporter-level batching, to every pipeline that sends data over the network.

ANTI-PATTERN 02Avoid
The Mistake

Placing the batch processor early, before filters, redaction or sampling.

Why It Hurts

Batches are formed and then shrunk or reshaped, wasting effort, creating uneven sizes and holding sensitive data longer than needed.

Better Approach

Make batching one of the last steps before the exporter.

ANTI-PATTERN 03Avoid
The Mistake

Setting a huge batch size and a long timeout without a max size.

Why It Hurts

Batches can exceed backend message limits and be rejected whole, and memory use can balloon.

Better Approach

Choose a moderate size, set a max size, and confirm the numbers against the backend’s limits.

ANTI-PATTERN 04Avoid
The Mistake

Treating the batch processor as a durable store that guarantees delivery.

Why It Hurts

It holds data in memory and reports success before data reaches the backend. A crash or long outage loses data silently.

Better Approach

Use exporter queues, disk storage where needed, and monitor the gap between received and exported counts.

ANTI-PATTERN 05Avoid
The Mistake

Using a high-cardinality value, such as a request ID, as a metadata key for batching.

Why It Hurts

Each unique value creates its own batch in memory, which can exhaust memory and defeat the purpose of batching.

Better Approach

Use only keys with a small, known set of values, such as a tenant or team, and keep the cardinality limit on.

15Best Practices and Common Mistakes

A practical checklist for healthy batching.

Best practices

  • Batch every networked pipeline. Traces, metrics and logs should all be grouped before leaving the Collector.
  • Put batching last. After protection, shaping and sampling, and just before export.
  • Start with defaults. Tune only after watching real behaviour.
  • Set a max size. Keep messages safely below your backend’s limits.
  • Pair with a memory limiter. Put it first, and size the container to match.
  • Add up delays. Count the timeouts at every layer, from SDK to gateway.
  • Keep metadata batching small. Use few keys with few values, and keep the limit on.
  • Plan for restarts. Allow graceful shutdown and consider disk-backed queues if loss is costly.
  • Monitor the batch metrics. Review trigger mix, batch sizes and drops regularly.
  • Check release notes. The recommended place for batching has been changing, so confirm advice for your version.

Common mistakes beginners make

  • Defining the batch processor but forgetting to list it in the pipeline.
  • Believing the send size is a hard limit, when it is only a trigger.
  • Forgetting that metrics are counted in data points, not in metric names.
  • Putting the batch processor before sampling or filtering.
  • Ignoring the combined delay of batching in several layers.
  • Assuming “accepted by the Collector” means “stored in the backend”.
  • Using unbounded metadata values and causing memory growth.

16Real-World and Industry Examples

How batching shows up in tools and platforms you may already know.

OpenTelemetry Helm Chart and Demos

The ready-made configurations used by the OpenTelemetry project for Kubernetes typically include a memory limiter and a batch processor in their pipelines. This shows how widely the “protect first, batch last” pattern is accepted as a sensible starting point.

AWS Distro for OpenTelemetry

Amazon’s distribution of the Collector provides example configurations that include batching before sending data to AWS monitoring services. Teams running on containers and serverless platforms use these as a base and then tune sizes and timeouts to their traffic.

Grafana Alloy

Grafana Alloy, an agent built on Collector components, offers a batch component with the same ideas of size, timeout and maximum size. Teams sending data to Grafana’s stack use it to reduce the number of requests and control message size.

Large E-Commerce Platforms

Companies that run very high traffic online stores typically place an agent Collector next to each service and a gateway Collector in front of their storage. Small, quick batches at the edge keep applications light. Larger batches at the gateway keep the cost of writing to storage under control during sales events.

Multi-Tenant Observability Providers

Providers that receive telemetry for many customers in one Collector layer use metadata-based batching so that each customer’s data is grouped and routed separately, with limits that stop one customer from consuming all the memory.

A typical journey for a growing team

1

Basic Setup

Memory limiter first and batch last, with default settings, in every pipeline.

2

Watch the Metrics

Build a small dashboard of batch triggers, sizes, refused data and exporter failures.

3

Set Safe Limits

Add a max size matched to the backend, and size container memory to match the settings.

4

Add Resilience

Add exporter queues with retries, and disk-backed storage where losing data is costly.

5

Review Regularly

Revisit settings when traffic changes, and read release notes about where batching is best done.

17Frequently Asked Questions

Quick answers to questions beginners ask most.

Q1What is batching in the Collector in one sentence?
It is grouping many small pieces of telemetry into larger bundles, and sending each bundle on when it is full or when a timer runs out, which makes sending much more efficient.
Q2Which component does the batching?
Mainly the batch processor, which sits in the Collector pipeline. Newer Collector versions also offer batching inside the exporter’s sending queue, so check which is recommended for your version.
Q3When is a batch sent?
When it reaches the configured size, or when the timeout expires, whichever happens first. On a clean shutdown, remaining data is also flushed.
Q4Is the batch size a strict limit?
No. It is a trigger. To enforce a firm upper limit, you must also set the maximum batch size, which splits larger bundles.
Q5What are the default settings?
Commonly, a timeout of 200 milliseconds and a send size of 8,192 items, with no maximum size. Defaults can change between versions, so confirm in the documentation for yours.
Q6Where should the batch processor go in the pipeline?
Near the end, after the memory limiter, enrichment, filtering, redaction and sampling, and just before the exporter.
Q7How does batching count metrics?
By data points, which are individual measurements. For traces it counts spans, and for logs it counts log records.
Q8Does batching make data arrive late?
Slightly. Data can wait up to the timeout in each batching layer. If you batch in the SDK, the agent and the gateway, the waits add up, so check the total.
Q9Can batching lose data?
Yes. Batches live in memory, so a crash can lose them, and the sender is told “received” before the data reaches the backend. Use exporter queues, disk-backed storage and monitoring to reduce the risk.
Q10Why is my backend rejecting batches?
Most often because the batches are larger than the backend allows. Set a maximum batch size below its limit, and check the Collector logs for size-related errors.
Q11Do I still need batching in the SDK if the Collector batches?
Yes. They serve different trips. SDK batching makes the trip from your application to the Collector efficient. Collector batching makes the trip from the Collector to the backend efficient.
Q12What does batching by metadata mean?
It means keeping separate batches for different values of chosen request details, such as a tenant ID, so that data from different senders is not mixed. Keep the number of distinct values small.

18Summary and Key Takeaways

If you remember only a few things, remember these.

Key Takeaways

  • Batching is the bus that leaves when full or on time. The Collector groups telemetry and sends each group when it reaches the target size or when the timeout expires, whichever comes first.
  • It makes sending cheaper. Fewer requests, better compression, gentler load on backends and lower CPU use all come from this one simple idea.
  • Send size is a trigger, max size is a limit. To keep messages below a backend’s limit, you must set the maximum size as well.
  • Place it last. Put the memory limiter first, shape and sample the data in the middle, and batch just before the exporter.
  • There are two buffers. The batch processor groups items, while the exporter queue holds finished batches during retries. Both live in memory unless you choose disk-backed storage.
  • Know the trade-offs. Batching adds delay, uses memory and can lose data on a crash, and the delay adds up across SDK, agent and gateway layers.
  • Tune with evidence. Start with defaults, read the batch processor’s own metrics, change one setting at a time, and check current guidance, since the best place to batch has been evolving.