Bonjour !
J'ai le XML suivant:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/content/Results.xsl"?>
<results>
<testcases file="tests/testcases.xml">
<testcase id="1">
<description1>website:orange.fr - website_url:https://www.orange.fr - website_port:443 - website_localisation:France - network:SITES_DISTANTS</description1>
<verifypositive>
<assert>Clients Orange</assert>
<success>true</success>
</verifypositive>
<verifyresponsecode-success>true</verifyresponsecode-success>
<verifyresponsecode-message>Passed HTTP Response Code Verification</verifyresponsecode-message>
<success>true</success>
<result-message>TEST CASE PASSED</result-message>
<responsetime>0.147</responsetime>
</testcase>
<testcase id="2">
<description1>website:google.com - website_url:https://www.google.com - website_port:443 - website_localisation:Etats-Unis - network:SITES_DISTANTS</description1>
<verifypositive>
<assert>Google</assert>
<success>true</success>
</verifypositive>
<verifyresponsecode-success>true</verifyresponsecode-success>
<verifyresponsecode-message>Passed HTTP Response Code Verification</verifyresponsecode-message>
<success>true</success>
<result-message>TEST CASE PASSED</result-message>
<responsetime>0.171</responsetime>
</testcase>
</testcases>
<test-summary>
<start-time>Sat 13 Jan 2018, 20:19:12</start-time>
<start-seconds>73152</start-seconds>
<start-date-time>2018-01-13T20:19:12</start-date-time>
<total-run-time>2.346</total-run-time>
<total-response-time>2.163</total-response-time>
<test-cases-run>12</test-cases-run>
<test-cases-passed>12</test-cases-passed>
<test-cases-failed>0</test-cases-failed>
<verifications-passed>36</verifications-passed>
<verifications-failed>0</verifications-failed>
<assertion-skips>0</assertion-skips>
<average-response-time>0.18</average-response-time>
<max-response-time>0.277</max-response-time>
<min-response-time>0.136</min-response-time>
<execution-aborted>false</execution-aborted>
<test-file-name>testcases</test-file-name>
</test-summary>
</results>
Et j'aurai besoin de créer de nouveaux éléments depuis un élément existant dans chaque occurrence ():
<description1>website:google.com - website_url:https://www.google.com - website_port:443 - website_localisation:Etats-Unis - network:SITES_DISTANTS</description1>
Pour avoir cela:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/content/Results.xsl"?>
<results>
<testcases file="tests/testcases.xml">
<testcase id="1">
<description1>website:orange.fr - website_url:https://www.orange.fr - website_port:443 - website_localisation:France - network:SITES_DISTANTS</description1>
<website>orange.fr </website>
<website_url>https://www.orange.fr</website_url>
<website_port>443</website_port>
<website_localisation>France</website_localisation>
<network>SITES_DISTANTS</network>
<verifypositive>
<assert>Clients Orange</assert>
<success>true</success>
</verifypositive>
<verifyresponsecode-success>true</verifyresponsecode-success>
<verifyresponsecode-message>Passed HTTP Response Code Verification</verifyresponsecode-message>
<success>true</success>
<result-message>TEST CASE PASSED</result-message>
<responsetime>0.147</responsetime>
</testcase>
<testcase id="2">
<description1>website:google.com - website_url:https://www.google.com - website_port:443 - website_localisation:Etats-Unis - network:SITES_DISTANTS</description1>
<website>google.com</website>
<website_url>:https://www.google.com</website_url>
<website_port>443</website_port>
<website_localisation>Etats-Unis</website_localisation>
<network>SITES_DISTANTS</network>
<verifypositive>
<assert>Google</assert>
<success>true</success>
</verifypositive>
<verifyresponsecode-success>true</verifyresponsecode-success>
<verifyresponsecode-message>Passed HTTP Response Code Verification</verifyresponsecode-message>
<success>true</success>
<result-message>TEST CASE PASSED</result-message>
<responsetime>0.171</responsetime>
</testcase>
</testcases>
<test-summary>
<start-time>Sat 13 Jan 2018, 20:19:12</start-time>
<start-seconds>73152</start-seconds>
<start-date-time>2018-01-13T20:19:12</start-date-time>
<total-run-time>2.346</total-run-time>
<total-response-time>2.163</total-response-time>
<test-cases-run>12</test-cases-run>
<test-cases-passed>12</test-cases-passed>
<test-cases-failed>0</test-cases-failed>
<verifications-passed>36</verifications-passed>
<verifications-failed>0</verifications-failed>
<assertion-skips>0</assertion-skips>
<average-response-time>0.18</average-response-time>
<max-response-time>0.277</max-response-time>
<min-response-time>0.136</min-response-time>
<execution-aborted>false</execution-aborted>
<test-file-name>testcases</test-file-name>
</test-summary>
</results>
Est-ce que cela est possible selon vous ?
Actuellement, je ne sais pas trop comment m'y prendre et voici ce que j'ai:
input {
beats {
port => 7001
}
}
filter {
xml {
source => "message"
target => "parsed"
}
}
output {
stdout { codec => rubydebug }
elasticsearch {
hosts => ["192.168.0.11:9200"]
index => "webinject-%{+YYYY.MM.dd}"
template => "/etc/logstash/templates/webinject.json"
template_name => "webinject"
}
}
J'ai réussi à faire des XPATH et à créer de nouveaux fields mais ces derniers ne sont pas créés dans les noeuds XML.
Merci !