<?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: XML data - multi value field extraction without using xpath in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95295#M24602</link>
    <description>&lt;P&gt;Here you go:&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;your_sourcetype&amp;gt;]
REPORT-extract-crit=extract_crit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_crit]
REGEX = (?ms)\&amp;lt;Grade\&amp;gt;Critical\&amp;lt;/Grade\&amp;gt;.+?\&amp;lt;Machines\&amp;gt;\s*(.+?)\s*\&amp;lt;/Machines\&amp;gt;
FORMAT = critbox::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;fields.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[critbox]
TOKENIZER=\&amp;lt;Machine.+?\&amp;gt;([^\&amp;lt;]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It would be possible without the TOKENIZER if the PCRE implementation would support variable-length look-behinds with an expression like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[test_crit]
REGEX = (?ms)(?&amp;lt;=\&amp;lt;Grade\&amp;gt;Critical\&amp;lt;/Grade\&amp;gt;.+?\&amp;lt;Machines\&amp;gt;.+?(?\&amp;lt;Machine path="[^\&amp;gt;]*"\&amp;gt;[^\&amp;lt;]+\&amp;lt;/Machine\&amp;gt;\s+)?)\&amp;lt;Machine path="[^\&amp;gt;]*"\&amp;gt;([^\&amp;lt;]+)\&amp;lt;/Machine\&amp;gt;
FORMAT = critbox::$1
MV_ADD=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think support for this has been added to python 2.7 (Splunk's using 2.6.4)&lt;/P&gt;</description>
    <pubDate>Sun, 05 Dec 2010 00:52:47 GMT</pubDate>
    <dc:creator>ziegfried</dc:creator>
    <dc:date>2010-12-05T00:52:47Z</dc:date>
    <item>
      <title>XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95289#M24596</link>
      <description>&lt;P&gt;I got stuck with extracting a multi value field from XML data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Results&amp;gt;
    &amp;lt;Result&amp;gt;
        &amp;lt;Grade&amp;gt;Error&amp;lt;/Grade&amp;gt;
        &amp;lt;MachinesFound&amp;gt;0&amp;lt;/MachinesFound&amp;gt;
        &amp;lt;Machines&amp;gt;
        &amp;lt;/Machines&amp;gt;
    &amp;lt;/Result&amp;gt;
    &amp;lt;Result&amp;gt;
        &amp;lt;Grade&amp;gt;Critical&amp;lt;/Grade&amp;gt;
        &amp;lt;MachinesFound&amp;gt;3&amp;lt;/MachinesFound&amp;gt;
        &amp;lt;Machines&amp;gt;
            &amp;lt;Machine path="some data"&amp;gt;BIZ\TOTO&amp;lt;/Machine&amp;gt;
            &amp;lt;Machine path="some data"&amp;gt;BIZ\TATA&amp;lt;/Machine&amp;gt;
            &amp;lt;Machine path="some data"&amp;gt;BIZ\TUTU&amp;lt;/Machine&amp;gt;
        &amp;lt;/Machines&amp;gt;
    &amp;lt;/Result&amp;gt;
    &amp;lt;Result&amp;gt;
        &amp;lt;Grade&amp;gt;Warning&amp;lt;/Grade&amp;gt;
        &amp;lt;MachinesFound&amp;gt;2&amp;lt;/MachinesFound&amp;gt;
        &amp;lt;Machines&amp;gt;
            &amp;lt;Machine path="some data"&amp;gt;BIZ\TCTC&amp;lt;/Machine&amp;gt;
            &amp;lt;Machine path="some data"&amp;gt;BIZ\TZTZ&amp;lt;/Machine&amp;gt;
        &amp;lt;/Machines&amp;gt;
    &amp;lt;/Result&amp;gt;
    &amp;lt;Result&amp;gt;
        &amp;lt;Grade&amp;gt;Passed&amp;lt;/Grade&amp;gt;
        &amp;lt;MachinesFound&amp;gt;1&amp;lt;/MachinesFound&amp;gt;
        &amp;lt;Machines&amp;gt;
            &amp;lt;Machine path="some data"&amp;gt;BIZ\TETE&amp;lt;/Machine&amp;gt;
        &amp;lt;/Machines&amp;gt;
    &amp;lt;/Result&amp;gt;
    &amp;lt;Result&amp;gt;
        &amp;lt;Grade&amp;gt;NotPerformed&amp;lt;/Grade&amp;gt;
        &amp;lt;MachinesFound&amp;gt;0&amp;lt;/MachinesFound&amp;gt;
        &amp;lt;Machines&amp;gt;
        &amp;lt;/Machines&amp;gt;
    &amp;lt;/Result&amp;gt;
&amp;lt;/Results&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am already extracting Grade and the concerning amount of MachinesFound:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[gradeextr]
REGEX = \&amp;lt;Grade\&amp;gt;([^\&amp;lt;]+)\&amp;lt;/Grade\&amp;gt;.*?\&amp;lt;MachinesFound\&amp;gt;(\d+)\&amp;lt;/MachinesFound\&amp;gt;
FORMAT= $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What is missing now are the concerning &lt;STRONG&gt;Machine names&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;xpath is easy...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; *| xpath "//Results/Result[Grade=\"Critical\"]/Machines/Machine" outfield=critbox
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...but unfortunately not an option.&lt;/P&gt;

&lt;P&gt;So I want to go via props/transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = \&amp;lt;Grade\&amp;gt;Critical\&amp;lt;/Grade\&amp;gt;.+?\&amp;lt;Machines\&amp;gt;.+\&amp;lt;Machine path="[^\&amp;gt;]*"\&amp;gt;([^\&amp;lt;]+)\&amp;lt;/Machine\&amp;gt;.+
FORMAT = critbox::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I try to extract multi values with...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MV_ADD = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...the &lt;STRONG&gt;critbox&lt;/STRONG&gt; field has 2 similar(!) values.&lt;/P&gt;

&lt;P&gt;Is it possible to extract a multi value field without xpath using props/transforms.conf ?&lt;/P&gt;

&lt;P&gt;I tried also with using fields.conf and TOKENIZER= without any success.&lt;/P&gt;

&lt;P&gt;Thanks for any new ideas...&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2010 00:11:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95289#M24596</guid>
      <dc:creator>meno</dc:creator>
      <dc:date>2010-11-29T00:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95290#M24597</link>
      <description>&lt;P&gt;From your explanation, I can't see a reason that you must extract using that one regex.  This works better:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[regex1]
REGEX = \&amp;lt;Grade\&amp;gt;([^\&amp;lt;]+)\&amp;lt;/Grade\&amp;gt;
FORMAT= grade::$1

[regex2]
REGEX = &amp;lt;MachinesFound\&amp;gt;(\d+)\&amp;lt;/MachinesFound\&amp;gt;
FORMAT= machine_count::$1

[regex3]
REGEX = \&amp;lt;Machine path="[^\&amp;gt;]*"\&amp;gt;([^\&amp;lt;]+)
FORMAT= machine_name::$1
MV_ADD= true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats sum(machine_count) as total_count values(machine_name) as machine_names by grade
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Nov 2010 10:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95290#M24597</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2010-11-29T10:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95291#M24598</link>
      <description>&lt;P&gt;I added more data to show the idea behind it.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2010 23:58:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95291#M24598</guid>
      <dc:creator>meno</dc:creator>
      <dc:date>2010-11-29T23:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95292#M24599</link>
      <description>&lt;P&gt;I do not need the path field. I want to create reports based on the amount of machines and their machinename, that are critical, error, warning,... machines. So critical, error, warning and so on must be connected with the concerning amount of machines.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2010 00:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95292#M24599</guid>
      <dc:creator>meno</dc:creator>
      <dc:date>2010-11-30T00:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95293#M24600</link>
      <description>&lt;P&gt;Ah, I see.  I will add another extraction above.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2010 00:15:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95293#M24600</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2010-11-30T00:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95294#M24601</link>
      <description>&lt;P&gt;Opened a bounty as this question gets a showstopper. Anybody could help us finding the error or confirm that this is not possible with props/transforms? Thanks a lot...&lt;/P&gt;</description>
      <pubDate>Thu, 02 Dec 2010 01:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95294#M24601</guid>
      <dc:creator>meno</dc:creator>
      <dc:date>2010-12-02T01:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95295#M24602</link>
      <description>&lt;P&gt;Here you go:&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;your_sourcetype&amp;gt;]
REPORT-extract-crit=extract_crit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_crit]
REGEX = (?ms)\&amp;lt;Grade\&amp;gt;Critical\&amp;lt;/Grade\&amp;gt;.+?\&amp;lt;Machines\&amp;gt;\s*(.+?)\s*\&amp;lt;/Machines\&amp;gt;
FORMAT = critbox::$1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;fields.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[critbox]
TOKENIZER=\&amp;lt;Machine.+?\&amp;gt;([^\&amp;lt;]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It would be possible without the TOKENIZER if the PCRE implementation would support variable-length look-behinds with an expression like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[test_crit]
REGEX = (?ms)(?&amp;lt;=\&amp;lt;Grade\&amp;gt;Critical\&amp;lt;/Grade\&amp;gt;.+?\&amp;lt;Machines\&amp;gt;.+?(?\&amp;lt;Machine path="[^\&amp;gt;]*"\&amp;gt;[^\&amp;lt;]+\&amp;lt;/Machine\&amp;gt;\s+)?)\&amp;lt;Machine path="[^\&amp;gt;]*"\&amp;gt;([^\&amp;lt;]+)\&amp;lt;/Machine\&amp;gt;
FORMAT = critbox::$1
MV_ADD=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think support for this has been added to python 2.7 (Splunk's using 2.6.4)&lt;/P&gt;</description>
      <pubDate>Sun, 05 Dec 2010 00:52:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95295#M24602</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-12-05T00:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95296#M24603</link>
      <description>&lt;P&gt;Hi Siegfried, you are my RegEx Hero! It's working now...&lt;BR /&gt;
Bounty is for you &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Ich habe mir daran echt die Zähne ausgebissen.&lt;BR /&gt;
Die Lösung bleibt im Alpenraum &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Viele Grüsse aus der Schweiz...&lt;/P&gt;</description>
      <pubDate>Sun, 05 Dec 2010 19:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95296#M24603</guid>
      <dc:creator>meno</dc:creator>
      <dc:date>2010-12-05T19:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: XML data - multi value field extraction without using xpath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95297#M24604</link>
      <description>&lt;P&gt;Freut mich, dass ich helfen konnte &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Sieht man sich im Jänner in San Francisco? Liebe Grüße aus Wien.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Dec 2010 01:40:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/XML-data-multi-value-field-extraction-without-using-xpath/m-p/95297#M24604</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-12-06T01:40:36Z</dc:date>
    </item>
  </channel>
</rss>

