Hi,
I am just beginning to learn ELK, Grok etc.
I recently installed Elastic Stack (ELK and Filebeat) to monitor RedHat JBoss Fuse log files.
My goal is to create new fields by applying Grok's xml filter and extract its value and put it into the field by mutate>replace method.
The GREEDYDATA:messagetext may contain different xml data depending on web services being called. Sometimes the fields will exist in header, sometimes in body, etc. Sometimes the data may contain soap message, sometimes plain in xml format.
Giving example below for one field "EAITransDate". Looking for "transactionDate" in messagetext and get its text value and put it into EAITransDate field.
By right Kibana should show some value in EAITransDate field, but it is blank. It does not show anything.
Anything wrong with this xpath => ["//*[local-name()='transactionDate']/text()","EAITransDate"]?
I event tried xpath => ["//transactionDate/text()","EAITransDate"] but its not working also.
Need help/advise.
The Grok filter I am using is given below.
filter {
grok {
match => {
message => "%{TIMESTAMP_ISO8601:logdate}%{SPACE}\|%{SPACE}%{LOGLEVEL:level}%{SPACE}\|%{SPACE}%{DATA:thread}%{SPACE}\|%{SPACE}%{DATA:category}%{SPACE}\|%{SPACE}%{DATA:bundle}%{SPACE}\|%{SPACE}%{GREEDYDATA:messagetext}"
}
}
mutate {
add_field => {"EAITransDate" => ""}
add_field => {"EAITransTime" => ""}
add_field => {"EAITransType" => ""}
. more fields
. some more fields
. some more fields
}
if "transactionDate" in [messagetext]{
xml{
source => "messagetext"
store_xml => "false"
xpath => ["//*[local-name()='transactionDate']/text()","EAITransDate"]
}
mutate {
replace => {
"EAITransDate" => "%{EAITransDate}"
}
}
}
}
Sample log line given below.... The greedydata varies depending on service being called by front end. Sometimes the field name is spelt differently or in different case (lower case, upper case).
2019-01-07 20:10:44,831 | INFO | qtp1223493273-50 | InquiryServices | 981 - org.apache.cxf.cxf-core - 3.0.4.redhat-621084 | Inbound Messagen | ----------------------------n | ID: 32850n | Address: http://localhost:9000/cxf/AccountInquiryServices?wsdln | Encoding: UTF-8n | Http-Method: POSTn | Content-Type: text/xml; charset=UTF-8n | Headers: {Accept=[application/soap+xml,multipart/related,text/*], accept-encoding=[gzip,deflate], ARM_CORRELATOR=[DoNotTraceLowerProtocol], connection=[keep-alive], content-type=[text/xml; charset=UTF-8], Host=[localhost:9000], IBM-WAS-CLIENT=[TRUE], SAVECONNECTION=[13425254451546863044797], SOAPAction=[""], transfer-encoding=[chunked], User-Agent=[IBM WebServices/1.0], wsdl=[]}n | Payload: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.eai.beans.com">
n | <soapenv:Header/>
n | <soapenv:Body>
n | <ws:InqRequest>
n | <applId>ML123</applId>
n | <applName>ML123</applName>
n | <applTransId>30245</applTransId>
n | <applUserId />
n | <bankCode>1236</bankCode>
n | <branchNumber>0987</branchNumber>
n | <custNo>15243636</custNo>
n | <transactionCode>XYZ001</transactionCode>
n | <transactionDate>28012019</transactionDate>
n | <transactionTime>152312</transactionTime>
n | <transactionUserId>NEWUSERID</transactionUserId>
n | <transactionUserInfo />
n | <versionNumber>1</versionNumber>
n | <versionNumber>1</versionNumber>
n | </ws:InqRequest>
n | </soapenv:Body>
n | </soapenv:Envelope>n | --------------------------------------
Thank you.