<?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: Multiple Value Field Extraction Help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74462#M18773</link>
    <description>&lt;P&gt;You can have multiple capturing groups in your regex. Is this what you're looking for?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "Hex-STRING: (?&amp;lt;mac_status&amp;gt;([a-fA-F0-9]{2}) (?&amp;lt;mac_vlan&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2}) (?&amp;lt;mac_addr&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2}) (?&amp;lt;mac_portid&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2}) 00"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Oct 2010 06:47:45 GMT</pubDate>
    <dc:creator>Ledion_Bitincka</dc:creator>
    <dc:date>2010-10-22T06:47:45Z</dc:date>
    <item>
      <title>Multiple Value Field Extraction Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74461#M18772</link>
      <description>&lt;P&gt;I am trying to come up with a Regex that will extract several field values from an event which can potentially have several occurrences of each field in a given event:&lt;/P&gt;

&lt;P&gt;One of the Regexes that I am working on so far is something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "Hex-STRING:\s(?&amp;lt;macstatus&amp;gt;([a-fA-F0-9][a-fA-F0-9]){1}?)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But i can't figure out how to account for multiple instances of the variable&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
Sample events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2010-10-20 08:39:21 switch.local [UDP: [192.168.1.6]:54862-&amp;gt;[192.168.1.16]]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (977272346) 113 days, 2:38:43.46, SNMPv2-MIB::snmpTrapOID.0 = OID: CISCO-MAC-NOTIFICATION-MIB::cmnMacChangedNotification, CISCO-MAC-NOTIFICATION-MIB::cmnHistMacChangedMsg.24 = Hex-STRING: &amp;lt;font color=22345&amp;gt;02 01 0F D4 9A 20 ED C6 7E 00 30 02 00 3C 00 23 32 2D E4 C0 01 F8 02 03 06 00 23 32 2D E4 C0 01 F8 00&amp;lt;/font&amp;gt; , CISCO-MAC-NOTIFICATION-MIB::cmnHistTimestamp.24 = Wrong Type (should be Timeticks): INTEGER: 977272346
2010-10-20 08:40:21 switch.local [UDP: [192.168.1.6]:62723-&amp;gt;[192.168.1.16]]: Trap , DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (977278346) 113 days, 2:39:43.46, SNMPv2-MIB::snmpTrapOID.0 = OID: CISCO-MAC-NOTIFICATION-MIB::cmnMacChangedNotification, CISCO-MAC-NOTIFICATION-MIB::cmnHistMacChangedMsg.25 = Hex-STRING: 01 01 0F D4 9A 20 ED C6 7E 00 30 00 , CISCO-MAC-NOTIFICATION-MIB::cmnHistTimestamp.25 = Wrong Type (should be Timeticks): INTEGER: 977278346
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
The string of Hex characters contains the information I am looking for.&lt;BR /&gt;
Every 11 octets of Hex represents one group.&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;For example, this would be one group (the final octet of '00' in each event marks the end of the string):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01 01 0F D4 9A 20 ED C6 7E 00 30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Each group consists of four fields.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;mac_status = Octet #1 
&lt;UL&gt;
&lt;LI&gt;Ex: &lt;EM&gt;(01)&lt;/EM&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;mac_vlan = Octet #2,3 
&lt;UL&gt;
&lt;LI&gt;Ex: &lt;EM&gt;(01 0F)&lt;/EM&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;mac_addr = Octet #4,5,6,7,8,9 
&lt;UL&gt;
&lt;LI&gt;Ex: &lt;EM&gt;(D4 9A 20 ED C6 7E)&lt;/EM&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;LI&gt;mac_portid = Octet #10,11 
&lt;UL&gt;
&lt;LI&gt;Ex: &lt;EM&gt;(00 30)&lt;/EM&gt;&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thank you,
David&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2010 05:00:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74461#M18772</guid>
      <dc:creator>jaoui</dc:creator>
      <dc:date>2010-10-21T05:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Value Field Extraction Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74462#M18773</link>
      <description>&lt;P&gt;You can have multiple capturing groups in your regex. Is this what you're looking for?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "Hex-STRING: (?&amp;lt;mac_status&amp;gt;([a-fA-F0-9]{2}) (?&amp;lt;mac_vlan&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2}) (?&amp;lt;mac_addr&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2}) (?&amp;lt;mac_portid&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2}) 00"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Oct 2010 06:47:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74462#M18773</guid>
      <dc:creator>Ledion_Bitincka</dc:creator>
      <dc:date>2010-10-22T06:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Value Field Extraction Help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74463#M18774</link>
      <description>&lt;P&gt;7 years after:&lt;/P&gt;

&lt;P&gt;This one fixes an issue with the Hex STRING being split by a newline. Documenting this in case it is of value to someone. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=50000 field=_raw "(?msi)Hex-STRING:\s?(?&amp;lt;Hex_STRING&amp;gt;.+)\t"
| rex field=Hex_STRING mode=sed "s/\s\n/ /g"
| rex max_match=50000 field=Hex_STRING "(?&amp;lt;mac_status&amp;gt;([a-fA-F0-9][a-fA-F0-9]){1}) (?&amp;lt;mac_vlan&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2}) (?&amp;lt;mac_addr&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2} [a-fA-F0-9]{2}) (?&amp;lt;mac_portid&amp;gt;[a-fA-F0-9]{2} [a-fA-F0-9]{2})"
| rex field=mac_vlan mode=sed "s/ //g"
| rex field=mac_portid mode=sed "s/ //g"
| rex field=mac_addr mode=sed "s/ /:/g"
| eval mac_addr=lower(mac_addr)
| stats latest(_time) AS _time values(host) AS host latest(mac_status) AS mac_status latest(mac_vlan) AS vlan latest(mac_portid) AS mac_portid BY mac_addr
| eval vlan=tonumber(vlan,16)
| eval mac_portid=tonumber(mac_portid,16)
| eval mac_status=tonumber(mac_status,16)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 May 2017 12:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Value-Field-Extraction-Help/m-p/74463#M18774</guid>
      <dc:creator>mikaelbje</dc:creator>
      <dc:date>2017-05-09T12:42:53Z</dc:date>
    </item>
  </channel>
</rss>

