# Can't get IIS Log row to match Grok-pattern

**URL:** <https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915>\
**Category:** Logstash\
**Created:** [January 21, 2020, 4:19pm UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915 "2020-01-21T16:19:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanwallenborg](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@johanwallenborg](https://discuss.elastic.co/u/johanwallenborg)\
**Post date:** [January 21, 2020, 4:19pm UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915/1 "2020-01-21T16:19:02Z")

</div>

Hello,

I'm getting grokfailures on some of the lines on my IIS log parsing and currently i'm banging my head towards a wall. 🙂

My pattern look like this:

`%{TIMESTAMP_ISO8601:iis.access.time} %{IPORHOST:destination.address} %{WORD:http.request.method} %{URIPATH:url.path} %{NOTSPACE:url.query} %{NUMBER:destination.port:long} %{NOTSPACE:user.name} %{IPORHOST:source.address} %{NOTSPACE:user_agent.original} %{NOTSPACE:http.request.referrer} %{NUMBER:http.response.status_code:long} %{NUMBER:iis.access.sub_status:long} %{NUMBER:iis.access.win32_status:long} %{NUMBER:http.response.body.bytes:long} %{NUMBER:http.request.body.bytes:long} %{NUMBER:event.duration:long} %{IPORHOST:temp.proxy.ip}`

And I want to match this row (probably more later):

`2019-09-30 00:34:07 1.1.1.1 GET / - 443 - 2.2.2.2 Pingdom.com_bot_version_1.4_(http://www.pingdom.com/),Pingdom.com_bot_version_1.4_(http://www.pingdom.com/) - 200 0 0 40844 206 204 -`

Can you see see something obvious? 🙂

---

<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:** [January 21, 2020, 8:20pm UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915/2 "2020-01-21T20:20:48Z")

</div>

- does not match IPORHOST. IPORHOST can contain -, but cannot start with it.

---

<div class="post-metadata">

**Author:** ![Fabio-sama](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@Fabio-sama](https://discuss.elastic.co/u/Fabio-sama)\
**Post date:** [January 22, 2020, 10:59am UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915/3 "2020-01-22T10:59:03Z")

</div>

> [@johanwallenborg](#):
>
> %{TIMESTAMP\_ISO8601:iis.access.time} %{IPORHOST:destination.address} %{WORD:http.request.method} %{URIPATH:url.path} %{NOTSPACE:url.query} %{NUMBER:destination.port:long} %{NOTSPACE:user.name} %{IPORHOST:source.address} %{NOTSPACE:user\_agent.original} %{NOTSPACE:http.request.referrer} %{NUMBER:http.response.status\_code:long} %{NUMBER:iis.access.sub\_status:long} %{NUMBER:iis.access.win32\_status:long} %{NUMBER:http.response.body.bytes:long} %{NUMBER:http.request.body.bytes:long} %{NUMBER:event.duration:long} %{IPORHOST:temp.proxy.ip}

Agree with Badger. Put `{IPORHOST:temp.proxy.ip}?` as you last match (basically add a question mark at the end of the grok).

---

<div class="post-metadata">

**Author:** ![johanwallenborg](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@johanwallenborg](https://discuss.elastic.co/u/johanwallenborg)\
**Post date:** [January 22, 2020, 4:50pm UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915/4 "2020-01-22T16:50:16Z")

</div>

> [@Fabio-sama](#):
>
> Agree with Badger. Put `{IPORHOST:temp.proxy.ip}?` as you last match (basically add a question mark at the end of the grok).

Thanks! 🙂  
But what difference makes ? at the end?

---

<div class="post-metadata">

**Author:** ![Fabio-sama](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@Fabio-sama](https://discuss.elastic.co/u/Fabio-sama)\
**Post date:** [January 22, 2020, 5:03pm UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915/5 "2020-01-22T17:03:25Z")

</div>

It makes all the difference. Because if you don't put the `?`, he looks for an IP or an HOST, find a `-` and breaks. If you put the `?` it looks for 0 or 1 occurrence of IP or HOST. It means that if it doesn't match any occurrences (as in your case since it finds `-` which is not matched by IPORHOST) it doesn't break.

---

<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:** [February 19, 2020, 5:03pm UTC](https://discuss.elastic.co/t/cant-get-iis-log-row-to-match-grok-pattern/215915/6 "2020-02-19T17:03:43Z")

</div>

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