# Grok Parsing

**URL:** <https://discuss.elastic.co/t/grok-parsing/309200>\
**Category:** Logstash\
**Created:** [July 8, 2022, 12:39pm UTC](https://discuss.elastic.co/t/grok-parsing/309200 "2022-07-08T12:39:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![escanor\_sama](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/escanor_sama/32/108072_2.png) [@escanor\_sama](https://discuss.elastic.co/u/escanor_sama)\
**Post date:** [July 8, 2022, 12:39pm UTC](https://discuss.elastic.co/t/grok-parsing/309200/1 "2022-07-08T12:39:05Z")

</div>

Hi everyone, I am having trouble when I want to parse this Fortigate Log  
\<189\>devname="FWFG240D" type="traffic" subtype="forward" level="notice" vd="root" eventtime=1565130979 srcip=146.0.138.202 srcport=61103 dstip=192.168.1.1 dstport=80 proto=6 action="accept" sentbyte=617

If someone can help me, please

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [July 8, 2022, 1:12pm UTC](https://discuss.elastic.co/t/grok-parsing/309200/2 "2022-07-08T13:12:31Z")

</div>

Your log is basically a key-value message, you do not need grok to parse it, you just need to split the part where you have the key-value pairs from the static part, the `<189>`, you can do this combining the `dissect` filter and the `kv` filter.

This is what I use to parse those Fortigate logs.

```auto
filter {    
    dissect {
        mapping => {
            "message" => "<%{}>%{[@metadata][kvmsg]}"
        }
        remove_field => ["message"]
    }
    kv {
        source => "[@metadata][kvmsg]"
    }
}

```

The `dissect` filter you get the key-value pairs into the nested field `@metadata.kvmsg`, I use the `@metadata` field because this field will not be present in the output document, you can user any other field name if you want the original key-value document present in your output, also, if the `dissect` is succesful, the original `message` field will be removed.

The `kv` filter will then parse your key-value document and give you the fields as named, for example, `devname`, `type`, `subtype` etc.

---

<div class="post-metadata">

**Author:** ![escanor\_sama](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/escanor_sama/32/108072_2.png) [@escanor\_sama](https://discuss.elastic.co/u/escanor_sama)\
**Post date:** [July 8, 2022, 2:03pm UTC](https://discuss.elastic.co/t/grok-parsing/309200/3 "2022-07-08T14:03:28Z")

</div>

Thank you, sir, it's really helpful I'll try it 😃

---

<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:** [August 5, 2022, 2:04pm UTC](https://discuss.elastic.co/t/grok-parsing/309200/4 "2022-08-05T14:04:16Z")

</div>

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