<?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 How to extract multiple values on one field from XML structured data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229729#M68049</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I want to split data from this XML structure, but I cannot because the extracted field only gets the first element.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;vuln:vulnerable-software-list&amp;gt;
      &amp;lt;vuln:product&amp;gt;cpe:/o:novell:opensuse:13.1&amp;lt;/vuln:product&amp;gt;
      &amp;lt;vuln:product&amp;gt;cpe:/a:samba:rsync:3.1.1&amp;lt;/vuln:product&amp;gt;
      &amp;lt;vuln:product&amp;gt;cpe:/o:novell:opensuse:13.2&amp;lt;/vuln:product&amp;gt;
  &amp;lt;/vuln:vulnerable-software-list&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I edited the file fields.conf too with the following syntax:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[name]
TOKENIZER = (cpe(:\/[\:\w\.]+))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But nothing happens. Any help? Thanks!&lt;/P&gt;

&lt;P&gt;Best regards, Buscatrufas&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2016 16:09:16 GMT</pubDate>
    <dc:creator>Buscatrufas</dc:creator>
    <dc:date>2016-06-27T16:09:16Z</dc:date>
    <item>
      <title>How to extract multiple values on one field from XML structured data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229729#M68049</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I want to split data from this XML structure, but I cannot because the extracted field only gets the first element.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;vuln:vulnerable-software-list&amp;gt;
      &amp;lt;vuln:product&amp;gt;cpe:/o:novell:opensuse:13.1&amp;lt;/vuln:product&amp;gt;
      &amp;lt;vuln:product&amp;gt;cpe:/a:samba:rsync:3.1.1&amp;lt;/vuln:product&amp;gt;
      &amp;lt;vuln:product&amp;gt;cpe:/o:novell:opensuse:13.2&amp;lt;/vuln:product&amp;gt;
  &amp;lt;/vuln:vulnerable-software-list&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I edited the file fields.conf too with the following syntax:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[name]
TOKENIZER = (cpe(:\/[\:\w\.]+))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But nothing happens. Any help? Thanks!&lt;/P&gt;

&lt;P&gt;Best regards, Buscatrufas&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 16:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229729#M68049</guid>
      <dc:creator>Buscatrufas</dc:creator>
      <dc:date>2016-06-27T16:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values on one field from XML structured data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229730#M68050</link>
      <description>&lt;P&gt;Are you sure you want to extract these at index time? It is unlikely that you really want to do that:&lt;/P&gt;

&lt;P&gt;From the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/Data/Configureindex-timefieldextraction"&gt;here&lt;/A&gt;: &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Caution: Do not add custom fields to the set of default fields that Splunk automatically extracts and indexes at index time unless absolutely necessary. This includes fields such as timestamp, punct, host, source, and sourcetype. Adding to this list of fields can negatively impact indexing performance and search times, because each indexed field increases the size of the searchable index. Indexed fields are also less flexible--whenever you make changes to your set of fields, you must re-index your entire dataset. For more information, see Index time versus search time in the Managing Indexers and Clusters manual.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Instead, you can use props.conf and transforms.conf to extract during search time,&lt;/P&gt;

&lt;P&gt;Let's say your data has a sourcetype of &lt;CODE&gt;vuln&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[vuln]
REPORT = vuln_extractions
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So whats going on here? The &lt;CODE&gt;REPORT&lt;/CODE&gt; tells Splunk to look in transforms.conf for a stanza called &lt;CODE&gt;vuln_extractions&lt;/CODE&gt;. It is simply linking the regular expression we will define to the &lt;CODE&gt;vuln&lt;/CODE&gt; sourcetype.&lt;/P&gt;

&lt;P&gt;Then we need Transfroms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[vuln_extractions]
REGEX = (?&amp;lt;_KEY_1&amp;gt;[\w\.]+):(?&amp;lt;_VAL_1&amp;gt;[\w\.]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whats going on here? The &lt;CODE&gt;REGEX&lt;/CODE&gt; line defines the regex we want to use. The &lt;CODE&gt;_KEY_1&lt;/CODE&gt; and &lt;CODE&gt;_VAL_1&lt;/CODE&gt; capture group names are &lt;STRONG&gt;special&lt;/STRONG&gt; and Splunk already knows what to do with them. You can read more about them and this approach in &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.1/Admin/Transformsconf"&gt;transforms.conf.spec&lt;/A&gt;. &lt;/P&gt;

&lt;P&gt;Here is an example of what the regex would extract: &lt;A href="https://regex101.com/r/lP9pQ7/1"&gt;regex101&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The transform should be applied by default, however, if you wanted to apply the same to a different sourcetype, ad-hoc, you could use the extract command to apply the transform, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=some_other_sourcetype | extract vuln
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2016 18:10:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229730#M68050</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2016-06-27T18:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values on one field from XML structured data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229731#M68051</link>
      <description>&lt;P&gt;I love you&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 07:32:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-on-one-field-from-XML-structured/m-p/229731#M68051</guid>
      <dc:creator>Buscatrufas</dc:creator>
      <dc:date>2016-06-28T07:32:20Z</dc:date>
    </item>
  </channel>
</rss>

