# Problem in my Groking

**URL:** <https://discuss.elastic.co/t/problem-in-my-groking/69582>\
**Category:** Logstash\
**Created:** [December 20, 2016, 2:27pm UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582 "2016-12-20T14:27:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [December 20, 2016, 2:27pm UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582/1 "2016-12-20T14:27:38Z")

</div>

Hi,

I have few entries in log that looks like that:

> <https://gist.github.com/ssasporta/1c05b0d63becdd0a57806277ff3212cc>

I am trying to build a grok that will fits them all, but have a problem where the string is : `Exception occurred in API invocation` More that, I need to try and catch the CM1-000259 which is the error code.

The grok I started to build:

`\<\<%{LOGLEVEL:severity}\>\> \[%{PARTTIMESTAMP:timestamp}\] \[\[%{DATA:status}\] %{DATA:exe_thread_details}\] \[%{DATA:application}\] \[%{DATA:user}\] \(%{JAVACLASS:class}\) %{WORD:exception_error} %{JAVAMETHOD:exception_method}`

More that, I have various customized grok patterns:

```
WEBLOGICTIMESTAMP %{MONTH} %{MONTHDAY}, %{YEAR} %{TIME} %{DL}
WEBLOGICTIMESTAMP_TZ %{MONTH} %{MONTHDAY}, %{YEAR} %{TIME} %{DL} ?%{TZ}?
DL ([P|A]M]?)
J2ES_TIMESTAMP %{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND}
TZ (?:[IPMCE][SD]T|UTC)
PARTTIMESTAMP %{MONTH} %{MONTHDAY} %{TIME}
# Java
JAVACLASS (?:[a-zA-Z$_][a-zA-Z$_0-9]*\.)*[a-zA-Z$_][a-zA-Z$_0-9]*
#Space is an allowed character to match special cases like 'Native Method' or 'Unknown Source'
JAVAFILE (?:[A-Za-z0-9_. -]+)
#Allow special <init>, <clinit> methods
JAVAMETHOD (?:(<(?:cl)?init>)|[a-zA-Z$_][a-zA-Z$_0-9]*)
#Line number is optional in special cases 'Native method' or 'Unknown source'
JAVASTACKTRACEPART %{SPACE}at %{JAVACLASS:class}\.%{JAVAMETHOD:method}\(%{JAVAFILE:file}(?::%{NUMBER:line})?\)
# Java Logs
JAVATHREAD (?:[A-Z]{2}-Processor[\d]+)
JAVALOGMESSAGE (.*)

```

The result I see in the grok debugger is:

{  
"severity": [  
[  
"DEBUG"  
]  
],  
"timestamp": [  
[  
"Feb 29 12:51:36"  
]  
],  
"MONTH": [  
[  
"Feb"  
]  
],  
"MONTHDAY": [  
[  
"29"  
]  
],  
"TIME": [  
[  
"12:51:36"  
]  
],  
"HOUR": [  
[  
"12"  
]  
],  
"MINUTE": [  
[  
"51"  
]  
],  
"SECOND": [  
[  
"36"  
]  
],  
"status": [  
[  
"ACTIVE"  
]  
],  
"exe\_thread\_details": [  
[  
"ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'"  
]  
],  
"application": [  
[  
"CM"  
]  
],  
"user": [  
[  
"ABPBatchUser"  
]  
],  
"class": [  
[  
"BasicCustomizationProxy.logACMException"  
]  
],  
**"exception\_error"** : [  
[  
**"Exception"**  
]  
],  
**"exception\_method"** : [  
[  
**"occurred"**  
]  
]  
}

Regards,  
Sharon.

---

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [December 20, 2016, 10:52pm UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582/2 "2016-12-20T22:52:26Z")

</div>

Hi,

Can someone try to help?

Regards,  
Sharon.

---

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [December 21, 2016, 7:42am UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582/3 "2016-12-21T07:42:25Z")

</div>

I think I have something working now.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 27, 2016, 6:56am UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582/4 "2016-12-27T06:56:10Z")

</div>

What ended up working?

---

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [December 27, 2016, 2:42pm UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582/5 "2016-12-27T14:42:39Z")

</div>

```
            grok {
                  tag_on_failure => ["BROKEN_GROK_SYSLOG", "_grokparsefailure"]
                  break_on_match => true
                  keep_empty_captures => false
                  match => { "message" => "\<\<%{LOGLEVEL:severity}\>\> \[%{PARTTIMESTAMP:timestamp}\] \[\[%{DATA}\] %{DATA}\] \[%{DATA:application}\] \(%{JAVACLASS}\) %{WORD}"}
                  patterns_dir => "/etc/logstash/patterns"
            }
            date {
                  match => ["timestamp" , "MMM dd HH:mm:ss"]
                  add_field => { "Status" => "Matched"}
                  #remove_field => ["timestamp"]
            }
```

---

<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:** [January 24, 2017, 2:42pm UTC](https://discuss.elastic.co/t/problem-in-my-groking/69582/6 "2017-01-24T14:42:41Z")

</div>

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