# Parsing hostname

**URL:** <https://discuss.elastic.co/t/parsing-hostname/57924>\
**Category:** Logstash\
**Created:** [August 12, 2016, 1:21pm UTC](https://discuss.elastic.co/t/parsing-hostname/57924 "2016-08-12T13:21:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rth](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rth](https://discuss.elastic.co/u/rth)\
**Post date:** [August 12, 2016, 1:21pm UTC](https://discuss.elastic.co/t/parsing-hostname/57924/1 "2016-08-12T13:21:13Z")

</div>

Hello,

I parse the hostname of the syslog source event with the following grok:

```
grok {
  match
=> [ "message", "%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST:hostname}
%{GREEDYDATA:mess}" ]
}

```

It works well for hostname in one word (eg: greentop) but doesn't work for hostname like this green\_top.

Any idea ?

Thanks

---

<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:** [August 12, 2016, 1:27pm UTC](https://discuss.elastic.co/t/parsing-hostname/57924/2 "2016-08-12T13:27:45Z")

</div>

Use NOSPACE instead of SYSLOGHOST.

Underscores aren't allowed in DNS hostnames which probably is why SYSLOGHOST doesn't include them.

---

<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, 4:43am UTC](https://discuss.elastic.co/t/parsing-hostname/57924/3 "2017-07-06T04:43:41Z")

</div>


