<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I extract specific data from a complex block of XML? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253895#M76025</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex ield=_raw "decision\&amp;gt;(?&amp;lt;decision&amp;gt;[^\&amp;lt;]+)\&amp;lt;" | rex field=_raw "reasonCode\&amp;gt;(?&amp;lt;reasonCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;\/" | where decision!="ACCEPT" | eventstats count as total by reasonCode | eval p=1/total | bin span=1d _time as time | stats sum(p) as perc by time reasonCode | eval perc=tostring(round(perc, 2), "commas") | eval time=strftime(time, "%x %X") | xyseries time reasonCode perc
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 18 May 2016 22:51:28 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-05-18T22:51:28Z</dc:date>
    <item>
      <title>How can I extract specific data from a complex block of XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253892#M76022</link>
      <description>&lt;P&gt;So I've been reading around and most people point to xpath, but after hours of troubleshooting I can't seem to get it to work in my scenario. I'm trying to extract &lt;STRONG&gt;decision&lt;/STRONG&gt; and &lt;STRONG&gt;reasoncode&lt;/STRONG&gt; as fields and report on them, but I just can't seem to get Splunk to recognize them in all of the outputs.&lt;/P&gt;

&lt;P&gt;So far I have this search working to report all failures (kind of). But I'm hoping for something better.&lt;/P&gt;

&lt;P&gt;Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=relevanthost "&amp;lt;c:decision&amp;gt;" "&amp;lt;c:reasonCode&amp;gt;" NOT "&amp;lt;c:decision&amp;gt;ACCEPT&amp;lt;/c:decision&amp;gt;"  
|xmlkv |timechart count by c:reasonCode limit=25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[2016-05-timestampstuff] [HOSTNAME] [NOTIFICATION] [numbers] [oracle.router.stuff] [tid: [ACTIVE].ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: &amp;lt;fakeuser&amp;gt;] [ecid: fakenumbersandlettersecid] [oracle.soa.tracking.FlowId: 000000000] [oracle.soa.tracking.InstanceId: 000000000] [oracle.soa.tracking.SCAEntityId: 00000] [FlowId:fakenumbersandletters] [[
 [OSB Tracing] Entering pipeline pair Process Request with message context: 
 [MessageContextImpl  uid="fakeuidlettersandnumbers"
 body="&amp;lt;soap:Body xmlns:soap="http://schemas.fake.url/soap/stuff"&amp;gt;
  &amp;lt;c:replyMessage xmlns:c="urn:fake.data.here"&amp;gt;
    &amp;lt;c:merchantReferenceCode&amp;gt;0000000000&amp;lt;/c:merchantReferenceCode&amp;gt;
    &amp;lt;c:requestID&amp;gt;0000000000000000000000&amp;lt;/c:requestID&amp;gt;
    &amp;lt;c:decision&amp;gt;ACCEPT&amp;lt;/c:decision&amp;gt;
    &amp;lt;c:reasonCode&amp;gt;100&amp;lt;/c:reasonCode&amp;gt;
    &amp;lt;c:requestToken&amp;gt;faketokenlettersandnumbers&amp;lt;/c:requestToken&amp;gt;
    &amp;lt;c:purchaseTotals&amp;gt;
      &amp;lt;c:currency&amp;gt;USD&amp;lt;/c:currency&amp;gt;
    &amp;lt;/c:purchaseTotals&amp;gt;
    &amp;lt;c:ccAuthReply&amp;gt;
      &amp;lt;c:reasonCode&amp;gt;100&amp;lt;/c:reasonCode&amp;gt;
      &amp;lt;c:amount&amp;gt;99.99&amp;lt;/c:amount&amp;gt;
      &amp;lt;c:authorizationCode&amp;gt;000000&amp;lt;/c:authorizationCode&amp;gt;
      &amp;lt;c:avsCode&amp;gt;X&amp;lt;/c:avsCode&amp;gt;
      &amp;lt;c:avsCodeRaw&amp;gt;A3&amp;lt;/c:avsCodeRaw&amp;gt;
      &amp;lt;c:cvCode&amp;gt;S&amp;lt;/c:cvCode&amp;gt;
      &amp;lt;c:cvCodeRaw&amp;gt;S&amp;lt;/c:cvCodeRaw&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 21:09:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253892#M76022</guid>
      <dc:creator>jtracy</dc:creator>
      <dc:date>2016-05-18T21:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract specific data from a complex block of XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253893#M76023</link>
      <description>&lt;P&gt;If you're only interested in the two fields, you're probably better off using &lt;CODE&gt;rex&lt;/CODE&gt;. Like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex ield=_raw "decision\&amp;gt;(?&amp;lt;decision&amp;gt;[^\&amp;lt;]+)\&amp;lt;" | rex field=_raw "reasonCode\&amp;gt;(?&amp;lt;reasonCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;\/" | where decision!="ACCEPT" | timechart count by reasonCode
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 21:23:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253893#M76023</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-18T21:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract specific data from a complex block of XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253894#M76024</link>
      <description>&lt;P&gt;This worked! Thanks! Would I be able to somehow use this to extrapolate what percentage each value for reasonCode represents in all results with "ACCEPT" as a value for decision in a timechart?&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 22:17:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253894#M76024</guid>
      <dc:creator>jtracy</dc:creator>
      <dc:date>2016-05-18T22:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract specific data from a complex block of XML?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253895#M76025</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... | rex ield=_raw "decision\&amp;gt;(?&amp;lt;decision&amp;gt;[^\&amp;lt;]+)\&amp;lt;" | rex field=_raw "reasonCode\&amp;gt;(?&amp;lt;reasonCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;\/" | where decision!="ACCEPT" | eventstats count as total by reasonCode | eval p=1/total | bin span=1d _time as time | stats sum(p) as perc by time reasonCode | eval perc=tostring(round(perc, 2), "commas") | eval time=strftime(time, "%x %X") | xyseries time reasonCode perc
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 22:51:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-specific-data-from-a-complex-block-of-XML/m-p/253895#M76025</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-18T22:51:28Z</dc:date>
    </item>
  </channel>
</rss>

