I have a log that has well-formed XML in it. I would like to parse out and extract several of the elements from that XML and publish them as fields in the /sprint/slic, my index/type pair.
Here is the data (two separate lines with \r at the end of each line):
[8/14/15 18:15:18:595] [DEBUG][main] HttpClient.submit - POST : <?xml version="1.0" encoding="UTF-8" standalone="yes"?><BillingAndCosting version="1.0"><ControlArea><**SenderId**>COMMERCIAL-BILLING_48012</SenderId><**WaterMark**>1419098400000</WaterMark><**RecordCount**>2</RecordCount><**TimeStamp**>2014-12-21T07:52:00.446-06:00</TimeStamp></ControlArea></BillingAndCosting>
[8/14/15 18:16:18:595] [DEBUG][main] end of post.
Now here is the Filter section of my Config file in which I'm attempting to provide field mapping from XML to document fields:
filter {
if [path] =~ "SLIC" {
mutate { replace => { "type" => "slic" } }
} else {
mutate { replace => { "type" => "sysout" } }
}
grok {
match => [
"message",
"^\[%{DATESTAMP:**tslice**}\] ... %{GREEDYDATA:**xmldata**}"
]
}
#if "_grokparsefailure" in [tags] {
# drop { }
#}
xml {
source => "xmldata"
add_field => {
"senderId" => "%{SenderId}"
#"waterMark" => "%{WaterMark}"
#"nbrOfAccounts" => "%{RecordCount}"
#"eventTimeStamp" => "%{TimeStamp}"
}
}
}
The above config did create the xmldata field in my document, but it didn't create the individual data fields from the xml document. Here is what's in the document data now:
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "sprint",
"_type" : "slic",
"_id" : "AU8zBckKlwBsRW10eWY3",
"_score" : 1.0,
"_source":{"message":"[8/14/15 18:15:18:595] [DEBUG][main] HttpClient.submit - POST : <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><BillingAndCosting version=\"1.0\"><ControlArea><SenderId>COMMERCIAL-BILLING_48012</SenderId><WaterMark>1419098400000</WaterMark><RecordCount>2</RecordCount><TimeStamp>2014-12-21T07:52:00.446-06:00</TimeStamp></ControlArea></BillingAndCosting>\r","@version":"1","@timestamp":"2015-08-15T20:21:00.228Z","host":"IBM-EN189AKEUJ4","path":"C:/logstash-1.5.3/demo/SystemSLICxml.log","type":"slic","tslice":"8/14/15 18:15:18:595","xmldata":"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><BillingAndCosting version=\"1.0\"><ControlArea><SenderId>COMMERCIAL-BILLING_48012</SenderId><WaterMark>1419098400000</WaterMark><RecordCount>2</RecordCount><TimeStamp>2014-12-21T07:52:00.446-06:00</TimeStamp></ControlArea></BillingAndCosting>\r","tags":["_xmlparsefailure"]}
} ]
}
}
How come it's not parsing out and creating these 4 fields for me in the Document?
"senderId" => "%{SenderId}"
"waterMark" => "%{WaterMark}"
"nbrOfAccounts" => "%{RecordCount}"
"eventTimeStamp" => "%{TimeStamp}"