# 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:** 1
**Showing post:** 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!

---

_[View the full topic](https://discuss.elastic.co/t/adding-logstash-ip-address-field-when-processing-filter/270055)._
