# Parsing a querystring from nginx

**URL:** <https://discuss.elastic.co/t/parsing-a-querystring-from-nginx/51248>\
**Category:** Logstash\
**Created:** [May 29, 2016, 2:21pm UTC](https://discuss.elastic.co/t/parsing-a-querystring-from-nginx/51248 "2016-05-29T14:21:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_6](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john\_6](https://discuss.elastic.co/u/john_6)\
**Post date:** [May 29, 2016, 2:21pm UTC](https://discuss.elastic.co/t/parsing-a-querystring-from-nginx/51248/1 "2016-05-29T14:21:09Z")

</div>

I have the following logstash filter so far:

```
filter {
  if [type] == "nginx-access" {
    grok {
      match => { "message" => "%{NGINXACCESS}" }
    }
    useragent {
      source => "agent"
      target => "ua"
    }
    geoip {
      source => "xff_clientip"
      target => "geoip"
      add_tag => ["nginx-geoip"]
      add_field => ["[geoip][coordinates]", "%{[geoip][longitude]}" ]
      add_field => ["[geoip][coordinates]", "%{[geoip][latitude]}" ]
    }
    mutate {
      split => { "x_forwarded_for" => ", " }
      convert => ["response", "integer"]
      convert => ["bytes", "integer"]
      convert => ["responsetime", "float"]
      convert => ["[geoip][coordinates]", "float"]
    }
  }
}

```

The message gets broken out into fields, one of which is the `request` being the url requested.

I would like to know what alterations I will need to grok this request field and use kv (I think it's kv) to break that into keys and values from the querystring?

The querystring will have array-like values in it, for example: `occasions[]=one&occasions[]=two` if that is going to cause any issues.

I'm pretty new to this, and kind of understand it, but any help would be appreciated 🙂

---

<div class="post-metadata">

**Author:** ![john\_6](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john\_6](https://discuss.elastic.co/u/john_6)\
**Post date:** [May 29, 2016, 2:29pm UTC](https://discuss.elastic.co/t/parsing-a-querystring-from-nginx/51248/2 "2016-05-29T14:29:33Z")

</div>

I jut tried:

```
kv {
  source => "request"
  target => "query"
  trim => "<>\[\],"
  field_split => "&"
}

```

but nothing seems to have changed after a restart of logstash. Have I got this wrong?

---

<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:** [May 29, 2016, 3:18pm UTC](https://discuss.elastic.co/t/parsing-a-querystring-from-nginx/51248/3 "2016-05-29T15:18:01Z")

</div>

Please give an example of a message you want to parse.

---

<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:55am UTC](https://discuss.elastic.co/t/parsing-a-querystring-from-nginx/51248/4 "2017-07-06T04:55:41Z")

</div>


