Hi Team
I am new to Kibana, logstash. I am trying push xml (generated as output of nunit) in logstash. I want to have the xml elements attributes, its Parents attributes and child attributes in the same row in Kibana.
However, i can get only the xml elements attribute. Parent and child attributes are not generated in the same row.
Below is the xml file:
<test-suite type="TestFixture" name="bootAPIs" executed="True" result="Failure" success="False" time="12.811" asserts="0">
<results>
<test-case name="NunitBETests.bootAPIs.GetSeriescount" executed="True" result="Success" success="True" time="0.944" asserts="0">
<reason name="NeededforBooting">
<message />
</reason>
</test-case>
<test-case name="NunitBETests.bootAPIs.GetData" executed="True" result="Success" success="True" time="0.910" asserts="0">
<reason>
<message />
</reason>
</test-case>
<test-case name="NunitBETests.bootAPIs.GetToken" executed="True" result="Success" success="True" time="0.462" asserts="0">
<reason>
<message />
e
</reason>
</test-case>
</results>
</test-suite>
Below is Logstash Config File I am using:
input { stdin { } }
filter {
xml {
store_xml => false
source => "message"
xpath =>
[
"//test-case/@name", "testcase",
"//test-case/@result", "res",
"//test-case/../../@name", "suitename",
"//test-case/reason/@name","reasonattr",
"//test-case/@time", "timetest"
]
}
date {
match => [ "date" , "dd-MM-yyyy HH:mm:ss" ]
timezone => "Europe/Amsterdam"
}
}
output {
elasticsearch {
action => "index"
index => "xml12"
hosts => ["localhost:9200"]
}
stdout { codec => rubydebug }
}
Result:
I am getting this output:
{
"message" => " <test-case name=\"NunitBETests.bootAPIs.GetSeriescount\" executed=\"True\" result=\"Success\" success=\"True\" time=\"0.462\" asserts=\"0\">\r",
"testcase" => [
[0] "NunitBETests.bootAPIs.GetSeriescount"
],
"res" => [
[0] "Success"
],
"host" => "DESKTOP-PC8JBMK"
}
However I am want to capture parent attribute of "testcase" node (that is "suitename") and child attribute of "testcase" xmlnode (that is "reasonattr") in same row.
Something like below is what i want to have:
{
"message" => " <test-case name=\"NunitBETests.bootAPIs.GetSeriescount\" executed=\"True\" result=\"Success\" success=\"True\" time=\"0.462\" asserts=\"0\">\r",
"testcase" => [
[0] "NunitBETests.bootAPIs.GetSeriescount"
],
"res" => [
[0] "Success"
],
"suitename" => [
[0] "bootAPIs"
],
"reasonattr" => [
[0] "NeededforBooting"
],
"@timestamp" => 2018-01-09T05:53:07.678Z,
"@version" => "1",
"timetest" => [
[0] "0.462"
],
"host" => "DESKTOP-PC8JBMK"
}
Please let me know what I am missing here.