I am trying to Parse XMl file , and adding extra field for test status . file is getting parsed but for New field , instead of getting value , its displaying filter itself. please suggest.. logstash.config file:
input {
file {
path => "C:/win10Automation/testng-results.xml"
start_position => "beginning"
type => "xml"
codec => multiline {
pattern => "^<\?xmldata .*\>"
negate => true
what => "previous"
}
}
#beats {
# port => "5044"
#}
}
filter {
xml {
remove_namespaces => true
source => "message"
store_xml => false
xpath =>
[
"/testng-results/suite/test/class/test-method", "test-method",
"/testng-results/suite/test/class/test-method[3]/@status", "test-status"
#"/testng-results/suite/test/class/test-method[(@status='PASS' or @status='FAIL' or @status='skipped') and contains(@signature ,"test()") ]","test-result"
]
}
mutate {
add_field => {"test-method" => "%{test-method]}"}
add_field => {"test-status" => "%{[test-status]}"}
add_field => {"test-result" => "%{test-result}"}
}
}
output {
elasticsearch {
codec => json
hosts => "localhost:9200"
index => "test10"
}
stdout {
codec => rubydebug
}
}
xml file :
<testng-results skipped="0" failed="0" total="10" passed="10">
<suite name="TestSuite" duration-ms="498075" started-at="2018-06-13T07:00:21Z" finished-at="2018-06-13T07:08:39Z">
<groups>
</groups>
<test name="UIHTML5TC10SettingSupportUI" duration-ms="20867" started-at="2018-06-13T07:00:21Z" finished-at="2018-06-13T07:00:42Z">
<class name="com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI">
<test-method status="PASS" signature="testSetup()[pri:0, instance:com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI@7e0e6aa2]" name="testSetup" is-config="true" duration-ms="14" started-at="2018-06-13T12:30:21Z" finished-at="2018-06-13T12:30:21Z">
<reporter-output>
</reporter-output>
</test-method> <!-- testSetup -->
<test-method status="PASS" signature="beforeMethod()[pri:0, instance:com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI@7e0e6aa2]" name="beforeMethod" is-config="true" duration-ms="24" started-at="2018-06-13T12:30:21Z" finished-at="2018-06-13T12:30:21Z">
<reporter-output>
</reporter-output>
</test-method> <!-- beforeMethod -->
<test-method status="PASS" signature="test()[pri:0, instance:com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI@7e0e6aa2]" name="test" duration-ms="19520" started-at="2018-06-13T12:30:21Z" finished-at="2018-06-13T12:30:40Z">
</test-method> <!-- test -->
<test-method status="PASS" signature="afterMethod()[pri:0, instance:com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI@7e0e6aa2]" name="afterMethod" is-config="true" duration-ms="172" started-at="2018-06-13T12:30:41Z" finished-at="2018-06-13T12:30:42Z">
<reporter-output>
</reporter-output>
</test-method> <!-- afterMethod -->
<test-method status="PASS" signature="testTearDown()[pri:0, instance:com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI@7e0e6aa2]" name="testTearDown" is-config="true" duration-ms="2" started-at="2018-06-13T12:30:42Z" finished-at="2018-06-13T12:30:42Z">
<reporter-output>
</reporter-output>
</test-method> <!-- testTearDown -->
</class> <!-- com.mtfilemedia.ifive.testscripts.UIHTML5TC10SettingSupportUI -->
</test>
in Kibana we get result test-status = %{[test-status]}, instead of value Pass,Fail, Please help