<?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 multivalue fields from XML data at search-time? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136363#M37296</link>
    <description>&lt;P&gt;Use &lt;CODE&gt;fields ID&lt;/CODE&gt; or &lt;CODE&gt;table ID&lt;/CODE&gt; rather than &lt;CODE&gt;return ID&lt;/CODE&gt; in your subsearch.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2015 12:53:41 GMT</pubDate>
    <dc:creator>aweitzman</dc:creator>
    <dc:date>2015-04-17T12:53:41Z</dc:date>
    <item>
      <title>How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136354#M37287</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I indexed a XML file and I am trying to extract some fields at search-time. &lt;/P&gt;

&lt;P&gt;What I'm trying to do is extract two fields, but I am failing because it is repeating. Right now, Splunk takes only my first match. Any help?? Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 12:57:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136354#M37287</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-15T12:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136355#M37288</link>
      <description>&lt;P&gt;Can you please show us the command you're using? For instance, when I do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 
| eval xml="[your XML above]" 
| rename xml as _raw 
| spath 
| table switch.powereddevice.macaddress switch.powereddevice.port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get two multivalued fields containing all the values.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:20:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136355#M37288</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-15T13:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136356#M37289</link>
      <description>&lt;P&gt;If you check out the doc on the rex command you'll see that &lt;CODE&gt;max_match=&lt;/CODE&gt; Controls the number of times the regex is matched. If greater than 1, the resulting fields will be multivalued fields. Defaults to 1, use 0 to mean unlimited.&lt;BR /&gt;
try like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex max_match=0    your_regex...
or 
...| rex max_match=0  field=_raw  your_regex...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;see this link to understand fine:&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/227331/using-rex-to-extract-multivalue-fields-from-events.html"&gt;http://answers.splunk.com/answers/227331/using-rex-to-extract-multivalue-fields-from-events.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136356#M37289</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-04-15T13:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136357#M37290</link>
      <description>&lt;P&gt;I didn't use a command. I uploaded the XML file and indexed it and now i'm trying to extract fields, because I will later need to use them for another search command. &lt;BR /&gt;
Just to explain better: I have other events (from a different source) and they have the IP addresses as fields. What I want is: based on an IP address,  search this XML file and get back the port and the macaddress&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:30:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136357#M37290</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-15T13:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136358#M37291</link>
      <description>&lt;P&gt;Until now I was trying to write a command using xpath, but was not working. I see that spath is much more helpful. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136358#M37291</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-15T13:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136359#M37292</link>
      <description>&lt;P&gt;Glad to hear it. Using that, you should be able to structure your search something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=myxmlfiles 
| spath 
| search switch.ipv4address="111.111.111.11"
| rename switch.ipv4address AS IPv4 switch.powereddevice.macaddress AS MACAddresses switch.powereddevice.port AS Ports
| table IPv4 MACAddresses Ports
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:45:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136359#M37292</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-15T13:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136360#M37293</link>
      <description>&lt;P&gt;You do not need to use a regular expression to obtain the data. Splunk is already instrumented with an automated extraction feature that will look into the XML and assign the value between the tags. A multi-value is normally handled. Let's ellaborate:&lt;/P&gt;

&lt;P&gt;Assume that you have a data point as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;switch&amp;gt;
    &amp;lt;managed&amp;gt;true&amp;lt;/managed&amp;gt;
       &amp;lt;ipv4address&amp;gt;111.111.111.11&amp;lt;/ipv4address&amp;gt;
       &amp;lt;powereddevice&amp;gt;
         &amp;lt;macaddress&amp;gt;000000000001&amp;lt;/macaddress&amp;gt;
         &amp;lt;port&amp;gt;11&amp;lt;/port&amp;gt;
       &amp;lt;/powereddevice&amp;gt;
       &amp;lt;powereddevice&amp;gt;
         &amp;lt;macaddress&amp;gt;000000000002&amp;lt;/macaddress&amp;gt;
         &amp;lt;port&amp;gt;9&amp;lt;/port&amp;gt;
       &amp;lt;/powereddevice&amp;gt;
       &amp;lt;powereddevice&amp;gt;
         &amp;lt;macaddress&amp;gt;000000000003&amp;lt;/macaddress&amp;gt;
         &amp;lt;port&amp;gt;7&amp;lt;/port&amp;gt;
       &amp;lt;/powereddevice&amp;gt;
       &amp;lt;powereddevice&amp;gt;
         &amp;lt;macaddress&amp;gt;000000000004&amp;lt;/macaddress&amp;gt;
         &amp;lt;port&amp;gt;5&amp;lt;/port&amp;gt;
       &amp;lt;/powereddevice&amp;gt;
       &amp;lt;powereddevice&amp;gt;
         &amp;lt;macaddress&amp;gt;000000000005&amp;lt;/macaddress&amp;gt;
         &amp;lt;port&amp;gt;3&amp;lt;/port&amp;gt;
       &amp;lt;/powereddevice&amp;gt;
       &amp;lt;powereddevice&amp;gt;
         &amp;lt;macaddress&amp;gt;000000000006&amp;lt;/macaddress&amp;gt;
         &amp;lt;port&amp;gt;1&amp;lt;/port&amp;gt;
       &amp;lt;/powereddevice&amp;gt;
&amp;lt;/switch&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is a generic inputs.conf configuration:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///media/answers/04-15-1015/1/]
disabled = false
index = test
sourcetype = answers-1429106201
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the companion props.conf. You need to call this explicitly.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[answers-1429106201]
KV_MODE = xml
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The end result is something like this:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/308i8A9356F841561F10/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;This KV_MODE property is a search-time change so you do not need to restart your Splunk instance. You will need to perform that change directly on the Search Head of your deployment.&lt;/P&gt;

&lt;P&gt;I hope this helps you,&lt;/P&gt;

&lt;P&gt;--&lt;BR /&gt;
gc&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 14:23:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136360#M37293</guid>
      <dc:creator>Gilberto_Castil</dc:creator>
      <dc:date>2015-04-15T14:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136361#M37294</link>
      <description>&lt;P&gt;It did help me. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2015 15:12:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136361#M37294</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-15T15:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136362#M37295</link>
      <description>&lt;P&gt;How can I find all events that have that MACaddress as a value in their field?&lt;BR /&gt;
What I want to achieve:&lt;BR /&gt;
In a subsearch, based on ipv4address, I want to retrieve all MAC addresses. Then, in my main search, I want to find all events that have that MACaddress as a value for the ID field and make a timechart.&lt;BR /&gt;
This is what I have so far:&lt;BR /&gt;
sourcetype=perfdata [search sourcetype=xmlConfig switch.ipv4address=111.111.111.11 | rename switch.powereddevice.macaddress AS ID | return ID]   | timechart span=5m values(field1) &lt;BR /&gt;
But I'm doing something wrong, because I get no results back.&lt;BR /&gt;
Do you have any suggestion?&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2015 08:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136362#M37295</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-17T08:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136363#M37296</link>
      <description>&lt;P&gt;Use &lt;CODE&gt;fields ID&lt;/CODE&gt; or &lt;CODE&gt;table ID&lt;/CODE&gt; rather than &lt;CODE&gt;return ID&lt;/CODE&gt; in your subsearch.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2015 12:53:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136363#M37296</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-17T12:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136364#M37297</link>
      <description>&lt;P&gt;I tried. Still not getting any results back. &lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2015 13:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136364#M37297</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-17T13:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136365#M37298</link>
      <description>&lt;P&gt;Hm. What happens when you run the following search:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=xmlConfig switch.ipv4address=111.111.111.11 | rename switch.powereddevice.macaddress AS ID | table ID | format&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;By adding &lt;CODE&gt;| format&lt;/CODE&gt; to the end of it, you can see what the text of the subsearch will be without it running. Is it what you are expecting?&lt;/P&gt;

&lt;P&gt;I just realized that ID is a multivalued field, and you might have to expand it. See if this closer to what you are expecting:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;sourcetype=xmlConfig switch.ipv4address=111.111.111.11 | rename switch.powereddevice.macaddress AS ID | mvexpand ID | table ID | format&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2015 13:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136365#M37298</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-17T13:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136366#M37299</link>
      <description>&lt;P&gt;I tried adding mvexpand and now it returns all the IDs that I was expecting. Thanks so much!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2015 13:29:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136366#M37299</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-17T13:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136367#M37300</link>
      <description>&lt;P&gt;Can you give me a hint on how I could retrieve the corresponding port for a specific macaddress?&lt;BR /&gt;
Right now, when I do the following query, I get all the ports:&lt;/P&gt;

&lt;P&gt;sourcetype=xmlConfig switch.powereddevice.macaddress=000000000001 |rename switch.powereddevice.port AS port | table port&lt;/P&gt;

&lt;P&gt;So, instead of getting only port "11", I get all "11,9,7,5,3,1" ports.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2015 14:27:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136367#M37300</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-17T14:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136368#M37301</link>
      <description>&lt;P&gt;In order to get the corresponding port to a particular MAC address, you need to associate them first using &lt;CODE&gt;mvzip&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval MACAndPort = mvzip(switch.powereddevice.macaddress,switch.powereddevice.port) | mvexpand MACAndPort | rex field=MACAndPort "(?&amp;lt;MAC&amp;gt;\d+),(?&amp;lt;Port&amp;gt;\d+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Apr 2015 14:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136368#M37301</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-17T14:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136369#M37302</link>
      <description>&lt;P&gt;*Update: solved this error: I tried, but I get error "Error in 'eval' command: The arguments to the 'mvzip' function are invalid." Should I add something to the mvzip function?&lt;/P&gt;

&lt;P&gt;**Update 2: I also found an answer for this question: But now my question is how could I retrieve only the port, based on a mac address? &lt;/P&gt;

&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2015 06:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136369#M37302</guid>
      <dc:creator>andra_pietraru</dc:creator>
      <dc:date>2015-04-19T06:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136370#M37303</link>
      <description>&lt;P&gt;Glad you figured out &lt;CODE&gt;mvzip&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Anyways, if you know what your MAC address is, just append &lt;CODE&gt;| where MAC=themacaddress&lt;/CODE&gt; to the end of your search string.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2015 12:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136370#M37303</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2015-04-20T12:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multivalue fields from XML data at search-time?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136371#M37304</link>
      <description>&lt;P&gt;+1 for &lt;CODE&gt;| rename xml as _raw&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2015 16:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multivalue-fields-from-XML-data-at-search-time/m-p/136371#M37304</guid>
      <dc:creator>joxley</dc:creator>
      <dc:date>2015-06-05T16:19:23Z</dc:date>
    </item>
  </channel>
</rss>

