# Can I add loadbalance to filebeat config for hosts in logstash output?

**URL:** https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378
**Category:** Beats
**Tags:** filebeat
**Created:** [June 20, 2016, 10:53pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378 "2016-06-20T22:53:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nanshan](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nanshan](https://discuss.elastic.co/u/nanshan)
#### Post date: [June 20, 2016, 10:53pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/1 "2016-06-20T22:53:33Z")

</div>

[https://www.elastic.co/guide/en/beats/filebeat/current/logstash-output.html](https://www.elastic.co/guide/en/beats/filebeat/current/logstash-output.html)

It says I can add a list of hosts in logstash output and enable loadbalancer

but I am not sure if I can just add the loadbalancer like : logstashhosts:5044  
logstashhosts is the name of a lb for logstash

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [June 21, 2016, 11:28am UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/2 "2016-06-21T11:28:12Z")

</div>

> [@nanshan](#):
>
> but I am not sure if I can just add the loadbalancer like : logstashhosts:5044logstashhosts is the name of a lb for logstash

I don't understand. Can you post sample configs?

e.g.

```auto
filebeat:
  ...

  spool_size: 4096

...

output:
  logstash:
    hosts:
      - logstash1:5044
      - logstash2:5044
    loadbalance: true
    bulk_max_size: 2048
    worker: 1

```

will get you some lock-step load-balancing. For lock-step loadbalancing use `spool_size = worker * #hosts * bulk_max_size`. Having just one host one can do (2 load balance workers):

```auto
filebeat:
  ...

  spool_size: 4096

...

output:
  logstash:
    hosts:
      - logstash:5044
    loadbalance: true
    bulk_max_size: 2048
    worker: 2

```

---

<div class="post-metadata">

### Author: ![nanshan](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nanshan](https://discuss.elastic.co/u/nanshan)
#### Post date: [June 21, 2016, 4:54pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/3 "2016-06-21T16:54:41Z")

</div>

sorry , let me make my question more clear.

output:  
logstash:  
hosts:  
- logstash1:5044  
- logstash2:5044

for the above configuration, can I give a loadbalancer name instead of giving a list of logstash hosts???  
Or I am misunderstanding loadbalancer here?

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [June 22, 2016, 3:41pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/4 "2016-06-22T15:41:08Z")

</div>

what kind of load-balancer are you using?

---

<div class="post-metadata">

### Author: ![nanshan](https://avatars.discourse-cdn.com/v4/letter/n/858c86/32.png) [@nanshan](https://discuss.elastic.co/u/nanshan)
#### Post date: [June 22, 2016, 6:07pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/5 "2016-06-22T18:07:33Z")

</div>

ELB

you are giving a list of logstash hosts, what if the two hosts are behind a loadbalancer?

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [June 22, 2016, 9:31pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/6 "2016-06-22T21:31:07Z")

</div>

The AWS ELB? Logstash output is not using HTTP, but sits right on top of TCP. ELB will balance connections round-robin. That is you can use logstash with `worker: 2` settings and the balancer it's address. But filebeat will keep connection until one logstash instance goes away. Starting multiple beats at the same time, there is a chance a beat might get all workers assigned to same host by ELB.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 11, 2016, 10:53pm UTC](https://discuss.elastic.co/t/can-i-add-loadbalance-to-filebeat-config-for-hosts-in-logstash-output/53378/7 "2016-07-11T22:53:42Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
