# Parse the middle of a loog

**URL:** <https://discuss.elastic.co/t/parse-the-middle-of-a-loog/127004>\
**Category:** Logstash\
**Created:** [April 5, 2018, 11:19pm UTC](https://discuss.elastic.co/t/parse-the-middle-of-a-loog/127004 "2018-04-05T23:19:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Herrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebastian_herrera/32/53209_2.png) [@Sebastian\_Herrera](https://discuss.elastic.co/u/Sebastian_Herrera)\
**Post date:** [April 5, 2018, 11:19pm UTC](https://discuss.elastic.co/t/parse-the-middle-of-a-loog/127004/1 "2018-04-05T23:19:31Z")

</div>

hello i am new with the filtering, i am having a log and i want to parse it but i am having an issue. My log is  
Mar 23 11:59:11 CLL21DCIDS01-IDS snort[26109]: [137:1:2] (spp\_ssl) Invalid Client HELLO after Server HELLO Detected [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 192.168.16.247:51650 -\> 52.184.227.73:443

i was hable to parse until (spp\_ssl). The thing is that now i want to save in a field all until [Priority but i dont know how. then i will continue parsing the priority the protocol and so on.

my filter now is this one

```
filter {
grok{
    match=>{"message"=>"%{SYSLOGTIMESTAMP:logDate} %{NOTSPACE:hostname} %{NOTSPACE:loglevel} \[%{NOTSPACE:mynumber}\] (%{NOTSPACE:otraVariable}) %{GREEDYDATA:message}"}
    overwrite => ["message"]
}
mutate {
        copy => { "loglevel" => "loglevel_tmp" }
       }
mutate {
        split => ["loglevel_tmp", "["]
        add_field => { "hostType" => "%{loglevel_tmp[0]}" }
        add_field => { "ruleId" => "%{loglevel_tmp[1]}" }
       }
mutate{
        remove_field => ["loglevel_tmp","loglevel"]
}

```

}

---

<div class="post-metadata">

**Author:** ![MariumHassan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mariumhassan/32/30321_2.png) [@MariumHassan](https://discuss.elastic.co/u/MariumHassan)\
**Post date:** [April 6, 2018, 12:27pm UTC](https://discuss.elastic.co/t/parse-the-middle-of-a-loog/127004/2 "2018-04-06T12:27:38Z")

</div>

Hi, I think this is what you are looking for:

```auto
grok{
    match=>{"message"=>"%{SYSLOGTIMESTAMP:logDate} %{NOTSPACE:hostname} %{NOTSPACE:loglevel} \[%{NOTSPACE:mynumber}\] (%{NOTSPACE:otraVariable}) %{DATA:data}Priority: %{INT:priority}"}
}

```

and then you can simply remove the field "data" using:

```auto
mutate 
{
  remove_field => ["data"]
}

```

---

<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:** [May 4, 2018, 12:28pm UTC](https://discuss.elastic.co/t/parse-the-middle-of-a-loog/127004/3 "2018-05-04T12:28:17Z")

</div>

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