Skip to content

This guide shows you how to distribute events across multiple destinations using the load_balance operator. You’ll learn to route events to multiple endpoints for high availability and throughput.

The load_balance operator spawns a nested pipeline for each element in a configuration list. Incoming events are distributed to exactly one of the nested pipelines, enabling you to spread load across multiple destinations.

let $endpoints = ["host1:8080", "host2:8080", "host3:8080"]
subscribe "events"
load_balance $endpoints {
write_json
save_tcp $endpoints
}

Each event goes to exactly one endpoint. The operator may reorder the event stream to optimize throughput.

Distribute events across multiple TCP receivers:

let $cfg = ["192.168.0.30:8080", "192.168.0.31:8080"]
subscribe "input"
load_balance $cfg {
write_json
save_tcp $cfg
}

Balance writes across Kafka clusters:

let $brokers = [
{host: "kafka1.example.com", topic: "events"},
{host: "kafka2.example.com", topic: "events"},
]
subscribe "events"
load_balance $brokers {
to_kafka $brokers.topic, options={"bootstrap.servers": $brokers.host}
}

Route to multiple Splunk instances, each with its own authentication:

let $cfg = [
{ip: "192.168.0.30", token: "token-1234"},
{ip: "192.168.0.31", token: "token-5678"},
]
subscribe "input"
load_balance $cfg {
let $endpoint = string($cfg.ip) + ":8088"
to_splunk $endpoint, hec_token=$cfg.token
}

Balance across OpenSearch clusters with per-cluster configuration:

let $clusters = [
{url: "https://es1.example.com:9200", index: "logs-primary"},
{url: "https://es2.example.com:9200", index: "logs-secondary"},
]
subscribe "logs"
load_balance $clusters {
to_opensearch $clusters.url, action="index", index=$clusters.index
}

Use load_balance when you need to:

  • Scale throughput: Distribute events across multiple receivers
  • Achieve high availability: Route to backup endpoints when primary is busy
  • Handle heterogeneous destinations: Route to endpoints with different credentials or configurations
OperatorBehaviorUse case
load_balanceEvents go to exactly one targetThroughput scaling, HA
forkEvents copied to all targetsParallel processing, archiving
publishEvents go to all subscribersFan-out to pipelines

The nested pipeline inside load_balance must end with a sink operator. The configuration variable must be declared with let before use.

Last updated: