<?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 Extracting multiple fields using makemv with a character class tokenizer to parse a Cisco MAC Notification MIB in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129741#M26630</link>
    <description>&lt;P&gt;Hi. I'm extracting Cisco SNMP traps (yay!) and in particular, the MAC notification MIB. I'm struggling to extract the multiple entries that can appear in the &lt;CODE&gt;string&lt;/CODE&gt; field.&lt;/P&gt;

&lt;P&gt;The string entry is output with no delimeters in the following tuples: Operation (2 chars), VLAN Id(4 chars), MAC(12 chars), D1BasePort Id(4 chars).&lt;/P&gt;

&lt;P&gt;Usually we find something like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;string=0x02003c90b11c5ec073000200&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;There's a single Operation (&lt;CODE&gt;02&lt;/CODE&gt;), with one associated VLAN Id (&lt;CODE&gt;003c&lt;/CODE&gt;), one MAC (&lt;CODE&gt;90b11c5ec073&lt;/CODE&gt;) and one baseport Id (&lt;CODE&gt;0002&lt;/CODE&gt;) and then a terminating (&lt;CODE&gt;00&lt;/CODE&gt;).&lt;/P&gt;

&lt;P&gt;However, you can of course have multiple MAC change notifications per VLAN and multiple baseport ids per operation. I've read through &lt;A href="http://answers.splunk.com/answers/46247/how-to-extract-mac-address-field-from-cisco-mac-address-notification-traps" target="_blank"&gt;this post&lt;/A&gt; and &lt;A href="http://answers.splunk.com/answers/85253/parse-cisco-snmp-trap-for-mac-address-and-status" target="_blank"&gt;this one&lt;/A&gt; and unfortunately they haven't quite got it right for MAC notification MIBs because &lt;STRONG&gt;there is a one-to-many relationship between the Operation and all of the subsequent fields&lt;/STRONG&gt;!&lt;/P&gt;

&lt;P&gt;So the &lt;CODE&gt;string&lt;/CODE&gt; field can also look like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;string=0x01004108000f5b547e008601004108000f543a1d000401004108000f560508009301004108000f7d19a000ad00&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;No delimiters whatsoever between the multiple tuples - nice. I want to loop through this string and extract each of the MAC change notifications. In the above string there are four notifications:&lt;/P&gt;

&lt;P&gt;a leading &lt;CODE&gt;0x&lt;/CODE&gt;, then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01004108000f5b547e0086
01004108000f543a1d0004
01004108000f5605080093
01004108000f7d19a000ad
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and lastly a terminating &lt;CODE&gt;00&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I reckon my tokenizer should look like this (switching to bold here because the board mangles the rest of my post if I continue with the code tag!):&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;makemv tokenizer="([0-9a-f]{2})([0-9a-f]{4})([0-9a-f]{12})([0-9a-f]{4})" string&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;or actually just:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;makemv tokenizer="([0-9a-f]{22})" string&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This splits the long concatenated string up. However when I view the output of the following query:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index=main sourcetype="cisco:snmp" string=0x01004108000f5b547e008601004108000f543a1d000401004108000f560508009301004108000f7d19a000ad00 | makemv tokenizer="([0-9a-f]{2})([0-9a-f]{4})([0-9a-f]{12})([0-9a-f]{4})" string | mvexpand string | rex "(?&lt;ACTION1&gt;[sa-fA-F0-9]{2})(?&lt;VLAN_HEX&gt;[sa-fA-F0-9]{4})(?&lt;MAC_ADDRESS&gt;[sa-fA-F0-9]{12})(?&lt;PORT_HEX&gt;[sa-fA-F0-9]{4})" | table action1, vlan_hex, mac_address, port_hex&lt;/PORT_HEX&gt;&lt;/MAC_ADDRESS&gt;&lt;/VLAN_HEX&gt;&lt;/ACTION1&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;(using the above example string) I get the following:&lt;/P&gt;

&lt;P&gt;action1 vlan_hex    mac_address     port_hex&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;/P&gt;

&lt;P&gt;So only the first entry is output. What I'd like to see is:&lt;/P&gt;

&lt;P&gt;action1 vlan_hex    mac_address     port_hex&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f543a1d    0086&lt;BR /&gt;
01      0041        08000f560508    0093&lt;BR /&gt;
01      0041        08000f7d19a0    00ad&lt;/P&gt;

&lt;P&gt;Does anyone have any ideas? Thanks and regards, Paul.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:59:23 GMT</pubDate>
    <dc:creator>paulrowen</dc:creator>
    <dc:date>2020-09-28T16:59:23Z</dc:date>
    <item>
      <title>Extracting multiple fields using makemv with a character class tokenizer to parse a Cisco MAC Notification MIB</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129741#M26630</link>
      <description>&lt;P&gt;Hi. I'm extracting Cisco SNMP traps (yay!) and in particular, the MAC notification MIB. I'm struggling to extract the multiple entries that can appear in the &lt;CODE&gt;string&lt;/CODE&gt; field.&lt;/P&gt;

&lt;P&gt;The string entry is output with no delimeters in the following tuples: Operation (2 chars), VLAN Id(4 chars), MAC(12 chars), D1BasePort Id(4 chars).&lt;/P&gt;

&lt;P&gt;Usually we find something like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;string=0x02003c90b11c5ec073000200&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;There's a single Operation (&lt;CODE&gt;02&lt;/CODE&gt;), with one associated VLAN Id (&lt;CODE&gt;003c&lt;/CODE&gt;), one MAC (&lt;CODE&gt;90b11c5ec073&lt;/CODE&gt;) and one baseport Id (&lt;CODE&gt;0002&lt;/CODE&gt;) and then a terminating (&lt;CODE&gt;00&lt;/CODE&gt;).&lt;/P&gt;

&lt;P&gt;However, you can of course have multiple MAC change notifications per VLAN and multiple baseport ids per operation. I've read through &lt;A href="http://answers.splunk.com/answers/46247/how-to-extract-mac-address-field-from-cisco-mac-address-notification-traps" target="_blank"&gt;this post&lt;/A&gt; and &lt;A href="http://answers.splunk.com/answers/85253/parse-cisco-snmp-trap-for-mac-address-and-status" target="_blank"&gt;this one&lt;/A&gt; and unfortunately they haven't quite got it right for MAC notification MIBs because &lt;STRONG&gt;there is a one-to-many relationship between the Operation and all of the subsequent fields&lt;/STRONG&gt;!&lt;/P&gt;

&lt;P&gt;So the &lt;CODE&gt;string&lt;/CODE&gt; field can also look like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;string=0x01004108000f5b547e008601004108000f543a1d000401004108000f560508009301004108000f7d19a000ad00&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;No delimiters whatsoever between the multiple tuples - nice. I want to loop through this string and extract each of the MAC change notifications. In the above string there are four notifications:&lt;/P&gt;

&lt;P&gt;a leading &lt;CODE&gt;0x&lt;/CODE&gt;, then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01004108000f5b547e0086
01004108000f543a1d0004
01004108000f5605080093
01004108000f7d19a000ad
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and lastly a terminating &lt;CODE&gt;00&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I reckon my tokenizer should look like this (switching to bold here because the board mangles the rest of my post if I continue with the code tag!):&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;makemv tokenizer="([0-9a-f]{2})([0-9a-f]{4})([0-9a-f]{12})([0-9a-f]{4})" string&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;or actually just:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;makemv tokenizer="([0-9a-f]{22})" string&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This splits the long concatenated string up. However when I view the output of the following query:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index=main sourcetype="cisco:snmp" string=0x01004108000f5b547e008601004108000f543a1d000401004108000f560508009301004108000f7d19a000ad00 | makemv tokenizer="([0-9a-f]{2})([0-9a-f]{4})([0-9a-f]{12})([0-9a-f]{4})" string | mvexpand string | rex "(?&lt;ACTION1&gt;[sa-fA-F0-9]{2})(?&lt;VLAN_HEX&gt;[sa-fA-F0-9]{4})(?&lt;MAC_ADDRESS&gt;[sa-fA-F0-9]{12})(?&lt;PORT_HEX&gt;[sa-fA-F0-9]{4})" | table action1, vlan_hex, mac_address, port_hex&lt;/PORT_HEX&gt;&lt;/MAC_ADDRESS&gt;&lt;/VLAN_HEX&gt;&lt;/ACTION1&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;(using the above example string) I get the following:&lt;/P&gt;

&lt;P&gt;action1 vlan_hex    mac_address     port_hex&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;/P&gt;

&lt;P&gt;So only the first entry is output. What I'd like to see is:&lt;/P&gt;

&lt;P&gt;action1 vlan_hex    mac_address     port_hex&lt;BR /&gt;
01      0041        08000f5b547e    0086&lt;BR /&gt;
01      0041        08000f543a1d    0086&lt;BR /&gt;
01      0041        08000f560508    0093&lt;BR /&gt;
01      0041        08000f7d19a0    00ad&lt;/P&gt;

&lt;P&gt;Does anyone have any ideas? Thanks and regards, Paul.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:59:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129741#M26630</guid>
      <dc:creator>paulrowen</dc:creator>
      <dc:date>2020-09-28T16:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple fields using makemv with a character class tokenizer to parse a Cisco MAC Notification MIB</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129742#M26631</link>
      <description>&lt;P&gt;This seems to work for me (run anywhere example)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|gentimes start=-1 | eval string="0x01004108000f5b547e008601004108000f543a1d000401004108000f560508009301004108000f7d19a000ad00" | makemv tokenizer="([0-9a-f]{22})" string| mvexpand string | rex field=string "(?&amp;lt;action1&amp;gt;[sa-fA-F0-9]{2})(?&amp;lt;vlan_hex&amp;gt;[sa-fA-F0-9]{4})(?&amp;lt;mac_address&amp;gt;[sa-fA-F0-9]{12})(?&amp;lt;port_hex&amp;gt;[sa-fA-F0-9]{4})" | table action1, vlan_hex, mac_address, port_hex
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jul 2014 13:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129742#M26631</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-07-03T13:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple fields using makemv with a character class tokenizer to parse a Cisco MAC Notification MIB</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129743#M26632</link>
      <description>&lt;P&gt;Was that it? I missing &lt;CODE&gt;field=string&lt;/CODE&gt;? Great, thanks - that works.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jul 2014 13:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129743#M26632</guid>
      <dc:creator>paulrowen</dc:creator>
      <dc:date>2014-07-03T13:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting multiple fields using makemv with a character class tokenizer to parse a Cisco MAC Notification MIB</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129744#M26633</link>
      <description>&lt;P&gt;For reference: yes, &lt;CODE&gt;field=string&lt;/CODE&gt; was missing as rex has to be told where to look for matches. Otherwise "_raw" is used per default, which may contain other data. But also the field extraction-terms (like &lt;CODE&gt;&amp;lt;action1&amp;gt;&lt;/CODE&gt;, &lt;CODE&gt;&amp;lt;vlan_hex&amp;gt;&lt;/CODE&gt;, ...) were missing in your search as these are necessary to fill your &lt;CODE&gt;table&lt;/CODE&gt; command with life (and to have correct &lt;CODE&gt;rex&lt;/CODE&gt;-syntax).&lt;/P&gt;

&lt;P&gt;Furthermore only &lt;CODE&gt;the first capturing group is used as a value of the newly created multivalue field&lt;/CODE&gt; (from the docs). This said the multiple use of capturing groups for filtering out different parts of the input string does not yield the desired result. A nice example for using more than one capturing groups to clearify how to exactly match a given string could be found in &lt;A href="https://answers.splunk.com/answers/81799/use-of-tokenizer-option-with-makemv.html" target="_blank"&gt;https://answers.splunk.com/answers/81799/use-of-tokenizer-option-with-makemv.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;What I am still wondering at is the "s" after each opening "[" in the regex. To my knowledge there's no special use of an "s" in a character set. And there won't be any "s" in a hex string (as indicated by &lt;CODE&gt;string=0x..."&lt;/CODE&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:16:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-multiple-fields-using-makemv-with-a-character-class/m-p/129744#M26633</guid>
      <dc:creator>rvany</dc:creator>
      <dc:date>2020-09-29T21:16:43Z</dc:date>
    </item>
  </channel>
</rss>

