<?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 to extract multiple values from XML logs and display all events where FieldA is not equal to FieldB? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275890#M83237</link>
    <description>&lt;P&gt;You can let Splunk extract all the XML fields automatically by changing the &lt;CODE&gt;props.conf&lt;/CODE&gt; file in the application of interested (say search).  &lt;/P&gt;

&lt;P&gt;Here is a stanza example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_xml_logs_source_type]
KV_MODE = xml
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Sep 2016 04:34:29 GMT</pubDate>
    <dc:creator>mIliofotou_splu</dc:creator>
    <dc:date>2016-09-08T04:34:29Z</dc:date>
    <item>
      <title>How to extract multiple values from XML logs and display all events where FieldA is not equal to FieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275886#M83233</link>
      <description>&lt;P&gt;I have some XML responses logged in Splunk which is pretty nested. Let's say there are multiple records of the form.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;records&amp;gt;
      &amp;lt;record&amp;gt;
        &amp;lt;Full Name&amp;gt;Ms. Brown Grimes&amp;lt;/Full Name&amp;gt;
        &amp;lt;Country&amp;gt;Dronning Maud Land&amp;lt;/Country&amp;gt;
        &amp;lt;NotificationEmail&amp;gt;Sam.Lemke@mckenzie.info&amp;lt;/NotificationEmail&amp;gt;
        &amp;lt;Created At&amp;gt;Fri Aug 25 1989 22:17:00 GMT-0700 (Pacific Daylight Time)&amp;lt;/Created At&amp;gt;
        &amp;lt;Id&amp;gt;10&amp;lt;/Id&amp;gt;
        &amp;lt;Email&amp;gt;Sam.Lemke@mckenzie.info&amp;lt;/Email&amp;gt;
      &amp;lt;/record&amp;gt;
      &amp;lt;record&amp;gt;
        &amp;lt;Full Name&amp;gt;Irma Ledner I&amp;lt;/Full Name&amp;gt;
        &amp;lt;Country&amp;gt;Vatican City&amp;lt;/Country&amp;gt;
        &amp;lt;NotificationEmail&amp;gt;GabrielleGmail@gmail.com&amp;lt;/NotificationEmail&amp;gt;
        &amp;lt;Created At&amp;gt;Tue Nov 30 1993 08:16:58 GMT-0800 (Pacific Standard Time)&amp;lt;/Created At&amp;gt;
        &amp;lt;Id&amp;gt;12&amp;lt;/Id&amp;gt;
        &amp;lt;Email&amp;gt;Gabrielle@myrl.biz&amp;lt;/Email&amp;gt;
      &amp;lt;/record&amp;gt;
    &amp;lt;/records&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to find all records where &lt;STRONG&gt;NotificationEmail&lt;/STRONG&gt; is not equal to &lt;STRONG&gt;Email&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;What I was trying was piping to regex extractor.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "&amp;lt;record.*NotificationEmail&amp;gt;(?&amp;lt;nemail&amp;gt;\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b)&amp;lt;.*Email&amp;gt;(?&amp;lt;email&amp;gt;\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b)&amp;lt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where &lt;CODE&gt;\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b&lt;/CODE&gt; is the regex to match email.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 18:57:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275886#M83233</guid>
      <dc:creator>anilkamath</dc:creator>
      <dc:date>2016-04-05T18:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values from XML logs and display all events where FieldA is not equal to FieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275887#M83234</link>
      <description>&lt;P&gt;You want to filter the whole response (records set) where any of the record has NotificationEmail is equal to Email OR filter the record, within a response (record set) which has NotificationEmail is equal to Email?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 21:14:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275887#M83234</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-04-05T21:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values from XML logs and display all events where FieldA is not equal to FieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275888#M83235</link>
      <description>&lt;P&gt;The problem is that you need to extract multiple copies of the fields - assuming that the event is defined by the "\" tag.&lt;BR /&gt;
Within the event, you have multiple values. There are a couple of ways to deal with this, but one would be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| rex maxmatch=0 "\&amp;lt;record\&amp;gt;(?&amp;lt;record&amp;gt;.*?)\&amp;lt;/record\&amp;gt;"
| mvexpand record
|rex "&amp;lt;record.*NotificationEmail&amp;gt;(?&amp;lt;nemail&amp;gt;\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b)&amp;lt;.*Email&amp;gt;(?&amp;lt;email&amp;gt;\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b)&amp;lt;"
| where nemail!=email
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first &lt;CODE&gt;rex&lt;/CODE&gt; and &lt;CODE&gt;mvexpand&lt;/CODE&gt; break the original event into multiple events, one for each "record." After that, the original &lt;CODE&gt;rex&lt;/CODE&gt; is applied and the comparison is made. I didn't verify that the regular expression is correct. Personally, I would have done something much more simple:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\&amp;lt;NotificationEmail\&amp;gt;(?&amp;lt;nemail&amp;gt;.*?)\&amp;lt;/NotificationEmail\&amp;gt;.*?\&amp;lt;Email\&amp;gt;(?&amp;lt;email&amp;gt;.*?)\&amp;lt;/Email\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2016 21:20:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275888#M83235</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-04-05T21:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values from XML logs and display all events where FieldA is not equal to FieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275889#M83236</link>
      <description>&lt;P&gt;Parsing XML with regex is a painful process, especially considering Splunk has commands tailored specifically for this.&lt;/P&gt;

&lt;P&gt;Note, your example is not valid XML - elements should not contain spaces in their names. Once that's fixed, you can run this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; search for your events | spath records.record | mvexpand records.record | spath input=records.record | where NOT Email=NotificationEmail
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will extract each record into its own event, parse the elements of the record, and filter according to the email fields.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 21:32:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275889#M83236</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-04-05T21:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values from XML logs and display all events where FieldA is not equal to FieldB?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275890#M83237</link>
      <description>&lt;P&gt;You can let Splunk extract all the XML fields automatically by changing the &lt;CODE&gt;props.conf&lt;/CODE&gt; file in the application of interested (say search).  &lt;/P&gt;

&lt;P&gt;Here is a stanza example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[my_xml_logs_source_type]
KV_MODE = xml
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Sep 2016 04:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-from-XML-logs-and-display-all/m-p/275890#M83237</guid>
      <dc:creator>mIliofotou_splu</dc:creator>
      <dc:date>2016-09-08T04:34:29Z</dc:date>
    </item>
  </channel>
</rss>

