# Can I grok out the host field if its not a valid IP? Also, what is the host field?

**URL:** <https://discuss.elastic.co/t/can-i-grok-out-the-host-field-if-its-not-a-valid-ip-also-what-is-the-host-field/120515>\
**Category:** Logstash\
**Created:** [February 19, 2018, 7:06pm UTC](https://discuss.elastic.co/t/can-i-grok-out-the-host-field-if-its-not-a-valid-ip-also-what-is-the-host-field/120515 "2018-02-19T19:06:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![red888](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@red888](https://discuss.elastic.co/u/red888)\
**Post date:** [February 19, 2018, 7:06pm UTC](https://discuss.elastic.co/t/can-i-grok-out-the-host-field-if-its-not-a-valid-ip-also-what-is-the-host-field/120515/1 "2018-02-19T19:06:01Z")

</div>

Not sure how to handle this.

I have this in my index template:  
"host": {  
"type": "IP"  
},

In logstash I have this:  
input {  
tcp {  
type =\> "weblogs"  
port =\> "9999"  
}  
}

Now on a production server "host" is always a valid IP address, but if Im running a logstash container locally and sending data to it from the host (my laptop) the "host" field is populated as "gateway" for some reason.

I was thinking about groking out the host field if it is not a valid IP, but then i realized I don't even know how this field gets in there. Is this a field logstash injects? it seems to be. And if its always just the IP or hostname of the server I suppose there is no real value to casting it as an IP anyway.

---

<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:** [February 20, 2018, 8:19pm UTC](https://discuss.elastic.co/t/can-i-grok-out-the-host-field-if-its-not-a-valid-ip-also-what-is-the-host-field/120515/2 "2018-02-20T20:19:57Z")

</div>

It's the tcp input that populates the `host` field. IIRC the hostname is used if available, otherwise you get an IP address.

---

<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:** [March 20, 2018, 8:20pm UTC](https://discuss.elastic.co/t/can-i-grok-out-the-host-field-if-its-not-a-valid-ip-also-what-is-the-host-field/120515/3 "2018-03-20T20:20:02Z")

</div>

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