I have an xml document having nested array elements for Test Case Run Summary . Since a Test Case contains multiple Test Steps, so in the document you will see multiple node and each node contains corresponding step information like <step_name>, <execution_status> etc.
Now when I used XML Filter to parse and extract step information from all the nodes, it generates output as an array element for all the nodes present under node like :-
"step_name" => [
[ 0] "Subprocess Login - Login",
[ 1] "Subprocess Login",
[ 2] "Subprocess Initiate_Reservation - Initiate_Reservation",
[ 3] "Subprocess Initiate_Reservation",
[ 4] "Subprocess Select_CarClass~1 - Select_CarClass",
[ 5] "Subprocess Select_CarClass~1",
[ 6] "Subprocess Get_CarClass_Details - Get_CarClass_Details",
[ 7] "Subprocess Update_Extras - Update_Extras",
[ 8] "Subprocess Commit_Reservation - Commit_Reservation",
[ 9] "Subprocess Commit_Reservation",
[10] "Subprocess Retrieve_Reservation - Retrieve_Reservation",
[11] "Subprocess Retrieve_Reservation",
[12] "Subprocess Cancel_Reservation - Cancel_Reservation",
[13] "Subprocess Cancel_Reservation",
[14] "Subprocess Retrieve_Reservation~1 - Retrieve_Reservation",
[15] "Subprocess Retrieve_Reservation~1",
[16] "Subprocess Cancel_Reservation~1 - Cancel_Reservation"
],
"execution_status" => [
[ 0] "PASSED",
[ 1] "PASSED",
[ 2] "PASSED",
[ 3] "PASSED",
[ 4] "PASSED",
[ 5] "PASSED",
[ 6] "PASSED",
[ 7] "PASSED",
[ 8] "PASSED",
[ 9] "PASSED",
[10] "PASSED",
[11] "PASSED",
[12] "PASSED",
[13] "PASSED",
[14] "PASSED",
[15] "PASSED"
]
Original XML document contains 18 step nodes. So XML Filter should extract 18 elements for step_name and execution_status". But as you can see from the above example, XML Filter extracted 18 elements for step_name and 16 elements for execution_status.
Need your help to understand, why the XML Filter is behaving like that?
Logstash CONF File:-
input {
file {
path => "//devcorp.deverac.local/dfsroot/NAS/data01_RQATtesting/ARS/Results/EMAGorilla/EGBO-RCQA/EGBO_Sanity_Suite/Run_10-15-2018_09-59-39-PM/EGBO_SANITY_02_AuthRes/Step_Detail_XML.xml"
start_position => "beginning"
sincedb_path => "NUL"
type => "xml"
codec => multiline {
pattern => ""
negate => "true"
what => previous
auto_flush_interval => 1
}
}
}
filter
{
xml {
source => "message"
target => "xmldata"
store_xml => false
xpath => [
"/testCase/tc_start_time/text()", "tc_start_time",
"/testCase/step/step_name/text()", "step_name",
"/testCase/step/execution_time_sec/text()","execution_time_sec",
"/testCase/step/execution_status/text()","execution_status"
]
}
mutate {
remove_field => [ "@timestamp","host","tags","@version","type","message"]
}
}
output {
stdout { codec => rubydebug }
}
Original XML Doc:-
<tc_id>C608690E65444B3F8A3B9DA25BA1493E</tc_id>
D08B65929BEC48B5BB4B5FF2843CA3B5
<tc_name>EGBO_SANITY_02_AuthRes</tc_name>
SERVICE
<tc_start_time>10/15/2018 09:56:43 PM</tc_start_time>
<tc_end_time>10/15/2018 09:57:10 PM</tc_end_time>
<tc_status>PASSED</tc_status>
<exec_time_sec>26 sec</exec_time_sec>
<tc_desc></tc_desc>
false
<step_id>B6059B588D8D49F2A75B972720BF6B6C</step_id>
<tc_id>C608690E65444B3F8A3B9DA25BA1493E</tc_id>
<session_id>D08B65929BEC48B5BB4B5FF2843CA3B5</session_id>
<step_name>Subprocess Login - Login</step_name>
<step_desc></step_desc>
<execution_time_sec>1 sec</execution_time_sec>
<execution_status>PASSED</execution_status>
<step_request>RQ_STEP-1.txt</step_request>
<step_response>RS_STEP-1.txt</step_response>
<image_content></image_content>
<step_err></step_err>
<step_warn></step_warn>
false
<step_response_header></step_response_header>
<step_start_time>1969-12-31T18:00:00-06:00</step_start_time>
Check HTTP Response Code
PASSED
<step_id>4116E443708D4B8C9F08CDF70127C307</step_id>
<tc_id>C608690E65444B3F8A3B9DA25BA1493E</tc_id>
<session_id>D08B65929BEC48B5BB4B5FF2843CA3B5</session_id>
<step_name>Subprocess Cancel_Reservation~1 - Cancel_Reservation</step_name>
<step_desc></step_desc>
<execution_time_sec>< 1 sec</execution_time_sec>
<execution_status>PASSED</execution_status>
<step_request>RQ_STEP-17.txt</step_request>
<step_response>RS_STEP-17.txt</step_response>
<image_content></image_content>
<step_err></step_err>
<step_warn></step_warn>
false
<step_response_header></step_response_header>
<step_start_time>1969-12-31T18:00:00-06:00</step_start_time>
Check HTTP Response Code
PASSED
<step_id>4BD6A6C384F840209E30E1CAC2002D21</step_id>
<tc_id>C608690E65444B3F8A3B9DA25BA1493E</tc_id>
<session_id>D08B65929BEC48B5BB4B5FF2843CA3B5</session_id>
<step_name>Subprocess Cancel_Reservation~1</step_name>
<step_desc></step_desc>
<execution_time_sec>< 1 sec</execution_time_sec>
<execution_status>PASSED</execution_status>
<step_request></step_request>
<step_response></step_response>
<image_content></image_content>
<step_err></step_err>
<step_warn></step_warn>
false
<step_response_header></step_response_header>
<step_start_time>1969-12-31T18:00:00-06:00</step_start_time>
Match Presence Of Error Code
PASSED
Match Presence Of Error Message
PASSED
<tc_sequence>3</tc_sequence>
Cannot provide you the complete XML Doc due to space limitation.It will be very helpful if you can help me out to resolve this weird issue.