The problem is in the log records, normally should be something like this: timestamp,loglevel, id, class, jboss_error or jboss error ode, logmsg. Your code is moved inside logmsg.
If error code always in format: *>> code: * this should work.
filter {
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:loglevel}\s+%{DATA:id}\s+\[%{DATA:class}\]\s+%{DATA:jboss_errors}:\s+%{GREEDYDATA:logmsg}"
}
}
if [jboss_errors] in ["FATAL", "CRITICAL"]{
grok {
match => { "logmsg" => ">>\s+%{DATA:[@metadata][msgerror]}:\s+"
}
}
mutate { copy => { "[@metadata][msgerror]" => "jboss_errors" } }
}
date {
match => ["timestamp", "ISO8601"]
timezone => "Europe/Berlin"
target=> "timestamp"
}
}
If this is JBoss EAP log, you can use the dictionary plugin for codes.
Result:
{
"loglevel" => "ERROR",
"message" => "2023-06-30 09:09:55,941 ERROR CUS.InEP-AAAA-123194144 [invocation] WFLYEJB0034: EJB Invocation failed on component Processor\r",
"@timestamp" => 2023-07-05T13:38:17.734780400Z,
"timestamp" => 2023-06-30T07:09:55.941Z,
"jboss_err_desc" => "EJB Invocation failed on component %s for method %s",
"jboss_errors" => "WFLYEJB0034",
"id" => "CUS.InEP-AAAA-123194144",
"logmsg" => "EJB Invocation failed on component Processor\r",
"class" => "invocation"
}
{
"loglevel" => "ERROR",
"message" => "2023-06-30 10:08:40,326 ERROR CUS.InEP-BBBB-121117180 [ExceptionLogger] FATAL: exception in processMessage: common.exception.Exception: [QQ_111] Packet Failed >> WFLYJPA0060: Packet is required to perform this operation (either use a packet or extended persistence context)\r",
"@timestamp" => 2023-07-05T13:38:17.736775700Z,
"timestamp" => 2023-06-30T08:08:40.326Z,
"jboss_err_desc" => "Transaction is required to perform this operation (either use a transaction or extended persistence context)",
"jboss_errors" => "WFLYJPA0060",
"id" => "CUS.InEP-BBBB-121117180",
"logmsg" => "exception in processMessage: common.exception.Exception: [QQ_111] Packet Failed >> WFLYJPA0060: Packet is required to perform this operation (either use a packet or extended persistence context)\r",
"class" => "ExceptionLogger"
}
This should work. Not sure does FATAL exist always or jboss_errors field will always exist. If does, then in 2nd grok use: logmsg instead message field
grok {
match => { "message" => "%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:loglevel}\s+%{DATA:id}\s+\[%{DATA:class}\]\s+%{DATA:jboss_errors}:\s+%{GREEDYDATA:logmsg}"
}
}
#if [jboss_errors] in ["FATAL", "CRITICAL"]{
grok { # or logmsg
match => { "message" => "(?<jbosserrorcode>\b(AMQ|ARJUNA|EJBCLIENT-|ELY|HCANN|HHH|HSEARCH|HV|IJ|ISNPHIB|ISPN|JB*|JIPI|JNDIWFHTTP|MODCLUSTER|MSC|PBOX|PROBE-|RESTEASY|TXNWFHTTP|UT|UTJS|VFS|WELD-|WF.*|XN.*|jlibaio)\d+\b):"
}
}
#}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.