# GROK Filter for Message to Pull Requested URL Path

**URL:** <https://discuss.elastic.co/t/grok-filter-for-message-to-pull-requested-url-path/67390>\
**Category:** Logstash\
**Created:** [November 28, 2016, 7:05pm UTC](https://discuss.elastic.co/t/grok-filter-for-message-to-pull-requested-url-path/67390 "2016-11-28T19:05:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Clarke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike_clarke/32/87948_2.png) [@Mike\_Clarke](https://discuss.elastic.co/u/Mike_Clarke)\
**Post date:** [November 28, 2016, 7:05pm UTC](https://discuss.elastic.co/t/grok-filter-for-message-to-pull-requested-url-path/67390/1 "2016-11-28T19:05:44Z")

</div>

Below is a sample of 2 messages that I receive and am trying to run through a GROK filter to capture the requested URL. I would like to discard everything starting with the ? until the next element which is the response code.

Without ? in URL path:  
`2016-14-12 14:45:33,655 [sdfsdfd] DEBUG were.were.werwer - Total TEST Time: 12591 for 1 total elements /teset/setset/setst/setwetghdfgh 200`

With ? in URL path:  
`2016-14-12 14:45:33,655 [sdfsdfd] DEBUG were.were.werwer - Total TEST Time: 12591 for 1 total elements /teset/setset/setst/setwetg?hdfgh 200`

Here is the GROK filter that I am trying to get to work:  
`.*Enrichment Time: %{NUMBER:enrich_time} for %{NUMBER:total_sel}.*selectors %{DATA:requesturl}.[^?]* %{NUMBER:statuscode}`

This filter will work fine for the message with the ? in the URL path but returns the below for the message without the ?.

````auto
  "enrich_time": [
    "12591"
  ],
  "total_sel": [
    "1"
  ],
  "requesturl": [
    ""
  ],
  "statuscode": [
    "200"
  ]
}```

I tried running the expression to look for either a ? or space but couldn't get the OR to work in the regex. Any suggestions?
````

---

<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:** [December 26, 2016, 7:06pm UTC](https://discuss.elastic.co/t/grok-filter-for-message-to-pull-requested-url-path/67390/2 "2016-12-26T19:06:19Z")

</div>

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