# Adding logstash IP address field when processing filter

**URL:** https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055
**Category:** Logstash
**Created:** [April 13, 2021, 7:16pm UTC](https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055 "2021-04-13T19:16:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yquirion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yquirion/32/107068_2.png) [@yquirion](https://discuss.elastic.co/u/yquirion)
#### Post date: [April 13, 2021, 7:16pm UTC](https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055/1 "2021-04-13T19:16:07Z")

</div>

Dear Elastic Community,

We are using several logstash servers behind a loadbalancer. All you client are sending their logs through those VIP created on the load balancer, not directly to the logstash servers. For the "beats", the load balancing is make by the beat itself, which contains the list of all logstash servers.

I would like to know if it is possible to add a field containing the logstash server IP address where the log ingestion has been processed from. If so, what would be the variable I need to add?

Thank you and best regards,  
Yanick Quirion

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [April 13, 2021, 10:05pm UTC](https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055/2 "2021-04-13T22:05:21Z")

</div>

See [here](https://discuss.elastic.co/t/how-can-i-get-the-logstash-hostname/51771/3).

---

<div class="post-metadata">

### Author: ![yquirion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yquirion/32/107068_2.png) [@yquirion](https://discuss.elastic.co/u/yquirion)
#### Post date: [April 22, 2021, 5:48pm UTC](https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055/3 "2021-04-22T17:48:33Z")

</div>

Thanks Badger!

The correct code was next though:

```auto
     ruby {
        init => "require 'socket'"
        code => "event.set('logstash.hostname', Socket.gethostname)"
      }

```

Regards!

---

<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: [May 20, 2021, 5:48pm UTC](https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055/4 "2021-05-20T17:48:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
