# How to create grok filter to parse the below log format

**URL:** <https://discuss.elastic.co/t/how-to-create-grok-filter-to-parse-the-below-log-format/295988>\
**Category:** Logstash\
**Created:** [February 1, 2022, 7:15pm UTC](https://discuss.elastic.co/t/how-to-create-grok-filter-to-parse-the-below-log-format/295988 "2022-02-01T19:15:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![poddraj](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@poddraj](https://discuss.elastic.co/u/poddraj)\
**Post date:** [February 1, 2022, 7:15pm UTC](https://discuss.elastic.co/t/how-to-create-grok-filter-to-parse-the-below-log-format/295988/1 "2022-02-01T19:15:12Z")

</div>

```auto
2022-02-01 01:25:45.778-[ActivationSrvc-28] com.verizon.vnm.activation.ejb.helper.ActivationRequestHelper.nbaReqResponse(ActivationRequestHelper.java:3313) INFO {"VSAD_ID":"ABFD","log_type":"","app_name":"ABC","VAST_ID":100,"function_name":"","log_time_stamp":null,"true_ip":"","Browser_thumbprint":"","View_port_x":"","View_port_y":"","Clicked_element":"","Click_x":"","Click_y":"","user_agent":"","user_device":"","logger_class":"","status_code":null,"page_name":"","customer_type":"IVAPP_PCRF","api_url":"","page_referer":"","http_verb":"","function_path":"","app_version":"","server_host":"","server_port":null,"app_flow":"","log_level":"","app_type":"WEBAPP(Java)","app_environment":"","log_message":"","app_session_id":"","sso_session_id":"","logged_in_user_id":"","journey_entry_point":"","type_alias":"","is_valued_transaction":"","transaction_value":"","is_account_info_view":"","account_info_view_type":"","is_account_info_change":"","account_info_change_type":"","app_level_info":null,"result_status":"V0000","response_size":"","version":1,"tid":"BCXVVCRF","transaction_id":"null","order_number":"","request_type":"PCQUERY"}

```

I want to parse only the content starting from {"VSAD\_ID: till end and push it to external system using logstash config. I tried below grok filter but I am getting error as below  
"Unexpected character ('-' (code 45)): Expected space separating root-level values\n

grok {  
match =\> { "message" =\> "%{TIMESTAMP\_ISO8601:timestamp} -`\`[%{DATA:instance}`\`] %{JAVACLASS:class}.%{WORD:method}(%{JAVAFILE:file}:%{NUMBER:line}) %{LOGLEVEL:log\_level}%{SPACE}%{GREEDYDATA:main\_message}" }  
}  
}

Can someone help me out here pls.  
I am ok if someone can show a way where I can ignore the content of the line till INFO and only consider from {"VSAID\_ID

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 1, 2022, 7:42pm UTC](https://discuss.elastic.co/t/how-to-create-grok-filter-to-parse-the-below-log-format/295988/2 "2022-02-01T19:42:16Z")

</div>

> [@poddraj](#):
>
> I am ok if someone can show a way where I can ignore the content of the line till INFO and only consider from {"VSAID\_ID

You could do that using

```
    dissect { mapping => { "message" => "%{}{%{[@metadata][restOfLine]}" } }
    mutate { gsub => ["[@metadata][restOfLine]", "^", "{" ] }
    json { source => "[@metadata][restOfLine]" remove_field => ["message"] }

```

If you want to use grok then remove the space after the timestamp and escape the parentheses

```
    grok { match => { "message" => "%{TIMESTAMP_ISO8601:timestamp}-\[%{DATA:instance}\] %{JAVACLASS:class}.%{WORD:method}\(%{JAVAFILE:file}:%{NUMBER:line}\) %{LOGLEVEL:log_level}%{SPACE}%{GREEDYDATA:main_message}" } }
    json { source => "main_message" remove_field => ["message", "main_message"] }

```

---

<div class="post-metadata">

**Author:** ![poddraj](https://avatars.discourse-cdn.com/v4/letter/p/5fc32e/32.png) [@poddraj](https://discuss.elastic.co/u/poddraj)\
**Post date:** [February 3, 2022, 7:32am UTC](https://discuss.elastic.co/t/how-to-create-grok-filter-to-parse-the-below-log-format/295988/3 "2022-02-03T07:32:59Z")

</div>

Thanx, I used grok one of above 2 and it worked.

---

<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:** [March 3, 2022, 7:33am UTC](https://discuss.elastic.co/t/how-to-create-grok-filter-to-parse-the-below-log-format/295988/4 "2022-03-03T07:33:36Z")

</div>

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