# Problem parsing with grok

**URL:** <https://discuss.elastic.co/t/problem-parsing-with-grok/154461>\
**Category:** Logstash\
**Created:** [October 29, 2018, 3:34pm UTC](https://discuss.elastic.co/t/problem-parsing-with-grok/154461 "2018-10-29T15:34:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Leite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/miguel_leite/32/41988_2.png) [@Miguel\_Leite](https://discuss.elastic.co/u/Miguel_Leite)\
**Post date:** [October 29, 2018, 3:34pm UTC](https://discuss.elastic.co/t/problem-parsing-with-grok/154461/1 "2018-10-29T15:34:44Z")

</div>

I'm trying to parse the following string using grok:

`(ADDRESS=(PROTOCOL=tcp)(HOST=172.18.213.2)(PORT=52737))`

I tried using the kv filter but I was having problems regarding the parenthesis...  
With the following pattern I got the results:

`\((?<field>[^)]*)\((?<prt>[^)]*)\)\((?<host>[^)]*)\)\((?<port>[^)]*)\)`

```
{
  "field": [
    [
      "ADDRESS="
    ]
  ],
  "prt": [
    [
      "PROTOCOL=tcp"
    ]
  ],
  "host": [
    [
      "HOST=172.18.213.2"
    ]
  ],
  "port": [
    [
      "PORT=52737"
    ]
  ]
}

```

Which is not exactly how I wanted to parse it. Can anyone help me? Maybe there is a way using the kv filter, which would be the easiest way to parse that log...

---

<div class="post-metadata">

**Author:** ![rijinmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rijinmp/32/24634_2.png) [@rijinmp](https://discuss.elastic.co/u/rijinmp)\
**Post date:** [October 30, 2018, 10:33am UTC](https://discuss.elastic.co/t/problem-parsing-with-grok/154461/2 "2018-10-30T10:33:00Z")

</div>

> [@Miguel\_Leite](#):
>
> (ADDRESS=(PROTOCOL=tcp)(HOST=172.18.213.2)(PORT=52737))

Check this grok filter:

> (%{DATA:field}=(%{DATA:prt})(%{DATA:host})(%{DATA:port}))

---

<div class="post-metadata">

**Author:** ![rijinmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rijinmp/32/24634_2.png) [@rijinmp](https://discuss.elastic.co/u/rijinmp)\
**Post date:** [October 30, 2018, 10:38am UTC](https://discuss.elastic.co/t/problem-parsing-with-grok/154461/3 "2018-10-30T10:38:49Z")

</div>

This filter wont work , some / are hided when I am pasted here

---

<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:** [November 27, 2018, 10:38am UTC](https://discuss.elastic.co/t/problem-parsing-with-grok/154461/4 "2018-11-27T10:38:56Z")

</div>

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