Splunk® Data Stream Processor

Function Reference

Download manual as PDF

Download topic as PDF

Batch Bytes

This topic describes how to use the function in the Splunk Data Stream Processor.


Batches incoming byte arrays by size, count, or milliseconds and outputs a single byte array concatenated by a user defined separator.

There are two functions for batching records: Batch Bytes and Batch Records. Use Batch Bytes when you need to serialize your data before batching. Use Batch Records when you want to do serialization (if any) after batching. Batch Bytes concatenates the batched byte array payloads delimited by an optional user-defined separator. This means that Batch Bytes is best used for row-based style batched payloads, such as CSV or JSON streaming (concatenated JSON records), but it will not be useful for bulk or columnar formats.

Function Input/Output Schema

Function Input
This function takes in byte arrays to be batched.
Function Output
This function outputs a byte array that is a concatenation of all byte[] payloads.


The required syntax is in bold.

bytes: <byte array>
separator: <string>
size: <string> B | KB | MB
num_events: <long>
millis: <long>

Required arguments

Syntax: byte[]
Description: The byte array payload to be batched.

Optional arguments

Syntax: <string>
Description: A delimiter that separates the byte payloads.
Example: \\n
Syntax: <string> B | KB | MB
Description: The maximum size, in bytes, of the emitted batched byte[]. The size of your emitted batched bytes cannot exceed 100 MB.
Default: 10MB
Example: 1024B
Syntax: <long>
Description: The maximum number of payloads per batch.
Default: 100,000,000
Example: 2000
Syntax: <long>
Description: The interval, in milliseconds, at which to send batched records.
Default: 10000 milliseconds (10 seconds).
Example: 2000


The following is an example of batched data. Assume that your data looks something like the following snippet, and you've configured your function with the arguments shown in the SPL2 example.

{"event": "my data 1", "index": "syslog", "sourcetype": "syslog"}
{"event": "my data 2", "index": "secindex", "sourcetype": "security"}
{"event": "my data 3", "index": "proxy", "sourcetype": "squid"}

When the batch trigger fires, Batch Bytes outputs a single record with a byte array.

Record {
   "bytes": byte[]

The outputted byte array is the following string as UTF-8 bytes.

{"event": "my data 1", "index": "syslog", "sourcetype": "syslog"}{"event": "my data 2", "index": "secindex", "sourcetype": "security"}{"event": "my data 3", "index": "proxy", "sourcetype": "squid"}

SPL2 examples

Suppose you have Splunk JSON events outputted by the to_splunk_json function. To batch bytes of those Splunk JSON events and only send payloads once they reach 5MB or 2 minutes have passed:

... | to_splunk_json index=cast(map_get(attributes, "index"), "string")  | batch_bytes bytes=to_bytes(json) size="5MB" millis="120000" |...;
Last modified on 19 August, 2020
Aggregate with Trigger
Batch Records

This documentation applies to the following versions of Splunk® Data Stream Processor: 1.1.0, 1.2.0

Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters