# How to extract the uri path and the param from the uri

**URL:** <https://discuss.elastic.co/t/how-to-extract-the-uri-path-and-the-param-from-the-uri/245521>\
**Category:** Logstash\
**Created:** [August 19, 2020, 4:41am UTC](https://discuss.elastic.co/t/how-to-extract-the-uri-path-and-the-param-from-the-uri/245521 "2020-08-19T04:41:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tristan\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tristan_d/32/73492_2.png) [@Tristan\_D](https://discuss.elastic.co/u/Tristan_D)\
**Post date:** [August 19, 2020, 4:41am UTC](https://discuss.elastic.co/t/how-to-extract-the-uri-path-and-the-param-from-the-uri/245521/1 "2020-08-19T04:41:15Z")

</div>

I want to extract the uri path and the param from the uri. There are two forms of the uri, one with params and one without.

Here is the examples of the uri

```auto
/sentence_func?key=23872323232
/bot_recognize

```

I use this pattern to match the uri  
`%{URIPATH:uri_path}(?:%{URIPARAM:param})|%{URIPATH:uri_path}`

But there are two results in the uri\_path with the [GROK DEBUGGER](https://grokdebug.herokuapp.com/). I don't want the null be in the output.

```auto
{
  "uri_path": [
    "/sentence_func",
    null
  ],
  "param": [
    "?key=23872323232"
  ]
}

```

Or like this output

```auto
{
  "uri_path": [
    null,
    "/bot_recognize"
  ],
  "param": [
    null
  ]
}

```

How can I remove the redundant result?

---

<div class="post-metadata">

**Author:** ![Tristan\_D](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tristan_d/32/73492_2.png) [@Tristan\_D](https://discuss.elastic.co/u/Tristan_D)\
**Post date:** [September 1, 2020, 11:43am UTC](https://discuss.elastic.co/t/how-to-extract-the-uri-path-and-the-param-from-the-uri/245521/2 "2020-09-01T11:43:20Z")

</div>

I used `%{URIPATH:uri}(%{URIPARAM})?` to get the desired result.

---

<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:** [September 29, 2020, 11:43am UTC](https://discuss.elastic.co/t/how-to-extract-the-uri-path-and-the-param-from-the-uri/245521/3 "2020-09-29T11:43:22Z")

</div>

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