# Using Extractors with grok Pattern

**URL:** <https://community.graylog.org/t/using-extractors-with-grok-pattern/16134>\
**Category:** Graylog Central (peer support)\
**Tags:** pipeline-rules\
**Created:** [June 30, 2020, 1:02pm UTC](https://community.graylog.org/t/using-extractors-with-grok-pattern/16134 "2020-06-30T13:02:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexnf](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexnf](https://community.graylog.org/u/Alexnf)\
**Post date:** [June 30, 2020, 1:02pm UTC](https://community.graylog.org/t/using-extractors-with-grok-pattern/16134/1 "2020-06-30T13:02:34Z")

</div>

Hi all,

i am quite new to this and would need some help understanding the Grok Patterns. I have tho following:

`date=2020-06-30 time=09:21:14 devname="600E" devid="FG6H0E5819904479" logid="0000000013" type="traffic" subtype="forward" level="notice" vd="root" eventtime=1593501674337461223 tz="+0200"`

i want to create an Extractor using Grok Pattern.

I started like this (I want year,month,day in separated fields):

`%{YEAR:IncYear}[-]%{MONTHNUM:IncMonth}[-]%{MONTHDAY:IncDay}`

which worked fine. How do I proceed from there i tried many of the time patten but none seem to work, or I (most likely use them wrong).

Maybe a kind soul can give me a push by highlighting how i can format the first 3-4 fields, I would highly appreciate it .

---

<div class="post-metadata">

**Author:** ![shoothub](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/shoothub/32/6412_2.png) [@shoothub](https://community.graylog.org/u/shoothub)\
**Post date:** [July 1, 2020, 9:03am UTC](https://community.graylog.org/t/using-extractors-with-grok-pattern/16134/2 "2020-07-01T09:03:19Z")

</div>

Don’t try to extract by one one, best way is to create extractor with key-value. This way, it extract all fields with key=value to separate fields.

[https://docs.graylog.org/en/3.3/pages/extractors.html?highlight=key%20value#automatically-extract-all-key-value-pairs](https://docs.graylog.org/en/3.3/pages/extractors.html?highlight=key%20value#automatically-extract-all-key-value-pairs)

By the way, fortigate uses 2 separate field to setup date and time, you can use this pipeline rule to concat them, and use it as timestamp:

```auto
rule "fortigate_timestamp"
when
  has_field("devname") AND has_field("date") AND has_field("time")
then
    let build_message_0 = concat(to_string($message.date), " ");
    let build_message_1 = concat(build_message_0, to_string($message.time));
    let new_time = parse_date(value: build_message_1, pattern:"yyyy-MM-dd HH:mm:ss", timezone:"Europe/Bratislava");
    set_field("timestamp", new_time);
end

```

Don’t forget to check processing order, so pipeline is after extractors in list  
[https://docs.graylog.org/en/3.3/pages/pipelines/stream\_connections.html?highlight=processing%20order#the-importance-of-message-processor-ordering](https://docs.graylog.org/en/3.3/pages/pipelines/stream_connections.html?highlight=processing%20order#the-importance-of-message-processor-ordering)

---

<div class="post-metadata">

**Author:** ![Alexnf](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Alexnf](https://community.graylog.org/u/Alexnf)\
**Post date:** [July 1, 2020, 11:21am UTC](https://community.graylog.org/t/using-extractors-with-grok-pattern/16134/3 "2020-07-01T11:21:15Z")

</div>

I can’t thank you enough. Works like a charm and is exactly what I needed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [July 15, 2020, 11:21am UTC](https://community.graylog.org/t/using-extractors-with-grok-pattern/16134/4 "2020-07-15T11:21:18Z")

</div>

Closed on July 15, 2020, 11:21am UTC

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