# How to get IP of machine in output?

**URL:** https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736
**Category:** Logstash
**Created:** [January 21, 2016, 7:14am UTC](https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736 "2016-01-21T07:14:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![punit\_naik1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/punit_naik1/32/7239_2.png) [@punit\_naik1](https://discuss.elastic.co/u/punit_naik1)
#### Post date: [January 21, 2016, 7:14am UTC](https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736/1 "2016-01-21T07:14:24Z")

</div>

Logstash by default appends hostname in the output. I wanted to append also the IP of that machine. How do I do this? Please help!

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 21, 2016, 6:52pm UTC](https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736/2 "2016-01-21T18:52:16Z")

</div>

Would the dns filter be helpful? Also, see below.

> [@Record originating IP of filebeats](https://discuss.elastic.co/t/record-originating-ip-of-filebeats/39151):
>
> I currently have a fairly simple setup consisting of running several filebeat instances on various hosts, talking to a central logstash instance, which in turn talks to a ES cluster (6 nodes total, 1 also runs logstash). Currently I only see the hostname of the hosts running filebeat, but I'd like to see the IP as well. Now I know that the hostname is sent by filebeat itself, and I'd prefer the IP address to be based on what logstash sees. Is this currently possible somehow? Otherwise I'd have …

---

<div class="post-metadata">

### Author: ![punit\_naik1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/punit_naik1/32/7239_2.png) [@punit\_naik1](https://discuss.elastic.co/u/punit_naik1)
#### Post date: [January 22, 2016, 6:09am UTC](https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736/3 "2016-01-22T06:09:29Z")

</div>

Actually that's not what I exactly want @magnusbaeck . I want the machine to write its IP address directly and not go through DNS. I want the IP address of eth0 interface to be precise. Isn't there a way in which I can sort of run a bash command inside the conf file and get the IP address of eth0 interface?

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 22, 2016, 6:51am UTC](https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736/4 "2016-01-22T06:51:50Z")

</div>

You could do that with a ruby filter, but keep in mind that running a process for every event becomes very costly as the event rate goes up. Another option could be to use the translate filter to add the IP address from a periodically reloaded external file. That file could e.g. be maintained by a cron job, depending on how often the IP address changes.

---

<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 6, 2017, 5:14am UTC](https://discuss.elastic.co/t/how-to-get-ip-of-machine-in-output/39736/5 "2017-07-06T05:14:50Z")

</div>


