# What's the best filter for path style url?

**URL:** <https://discuss.elastic.co/t/whats-the-best-filter-for-path-style-url/109179>\
**Category:** Logstash\
**Created:** [November 27, 2017, 8:17am UTC](https://discuss.elastic.co/t/whats-the-best-filter-for-path-style-url/109179 "2017-11-27T08:17:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![helloEson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/helloeson/32/28629_2.png) [@helloEson](https://discuss.elastic.co/u/helloEson)\
**Post date:** [November 27, 2017, 8:17am UTC](https://discuss.elastic.co/t/whats-the-best-filter-for-path-style-url/109179/1 "2017-11-27T08:17:14Z")

</div>

I want to extract the params in a path style url, it's something like this:  
/cid/27/end/2017-12-15/format/json/pid/1600

and the result i want is like this: cid=27,end=2017-12-15,format=json,pid=1600

Is there any good filter plugin can doing this ?

Thanks guys.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 27, 2017, 8:39am UTC](https://discuss.elastic.co/t/whats-the-best-filter-for-path-style-url/109179/2 "2017-11-27T08:39:50Z")

</div>

I think you might be able to do this using the [dissect filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html) and _indirect field notation_ option (see documentation).

---

<div class="post-metadata">

**Author:** ![helloEson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/helloeson/32/28629_2.png) [@helloEson](https://discuss.elastic.co/u/helloEson)\
**Post date:** [November 27, 2017, 9:03am UTC](https://discuss.elastic.co/t/whats-the-best-filter-for-path-style-url/109179/3 "2017-11-27T09:03:15Z")

</div>

@Christian_Dahlqvist Thanks for your kind response.

Because of the unsure position of these parameters, the dissect filter may not help. and I decide to change my goal. Below is my method to extract some of those fields:

input {  
file {  
path =\> ["/data0/logs/nginx/test.log"]  
}  
}

filter {  
grok {  
match =\> {  
"message" =\> "...(?\<query\_string\>(/[a-zA-Z0-9-\_]+)\*)..."  
}  
overwrite =\> ["host"]  
}  
if [query\_string] {  
grok {  
match =\> {  
"query\_string" =\> "/pid/(?\d+)"  
}  
}  
grok {  
match =\> {  
"query\_string" =\> "/cid/(?\d+)"  
}  
}  
}  
}

output {  
stdout { codec =\> rubydebug }  
}

=======================================  
And finally what the result looks like this:

{  
"method" =\> "GET",  
"upstream\_addr" =\> "172.16.1.12:9000",  
"body\_bytes\_sent" =\> "3415",  
"reqest\_time" =\> "0.025",  
"pid" =\> "1600",  
"@timestamp" =\> 2017-11-27T08:53:24.315Z,  
"@version" =\> "1",  
"host" =\> "[api.local.biz.com](http://api.local.biz.com)",  
"client" =\> "127.0.0.1",  
"upstream\_response\_time" =\> "0.025",  
"time" =\> "24/Nov/2017:00:11:37 +0800",  
"query\_string" =\> "/cid/27/start/2017-12-15/format/json/pid/1600",  
"status" =\> "200",  
"cid" =\> "27"  
}

---

<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 25, 2017, 9:03am UTC](https://discuss.elastic.co/t/whats-the-best-filter-for-path-style-url/109179/4 "2017-12-25T09:03:15Z")

</div>

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