<?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 do I extract a numerical field and rename the value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216500#M63538</link>
    <description>&lt;P&gt;worked perfectly. i had the lookup but i wasn't sure how to break it down correctly. much thanks!!&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2016 14:18:54 GMT</pubDate>
    <dc:creator>rwiley</dc:creator>
    <dc:date>2016-11-11T14:18:54Z</dc:date>
    <item>
      <title>How do I extract a numerical field and rename the value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216497#M63535</link>
      <description>&lt;P&gt;this is the raw data from my search   &lt;CODE&gt;index=myindex sourceype=mysourcetype&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-11-10 07:41:29 Local7.Debug    22.85.184.15    community=PUBLIC, enterprise=1.3.6.1.4.1.1046.11.1.1.1, uptime=25949301, agent_ip=, version=Ver2, 1.3.6.1.4.1.1046.11.1.1.1.1.1=2, 1.3.6.1.4.1.1046.11.1.1.1.1.2=0, 1.3.6.1.4.1.1046.11.1.1.1.1.3=0, 1.3.6.1.4.1.1046.11.1.1.1.1.4=1, 1.3.6.1.4.1.1046.11.1.1.1.1.5=1, 1.3.6.1.4.1.1046.11.1.1.1.1.6=1, 1.3.6.1.4.1.1046.11.1.1.1.1.7=2, 1.3.6.1.4.1.1046.11.1.1.1.1.8=30, 1.3.6.1.4.1.1046.11.1.1.1.1.9=0, 1.3.6.1.4.1.1046.11.1.1.1.1.10=426353, 1.3.6.1.4.1.1046.11.1.1.1.1.11=1478789235, 1.3.6.1.4.1.1046.11.1.1.1.1.12=1478788830, 1.3.6.1.4.1.1046.11.1.1.1.1.13=1478786400, 1.3.6.1.4.1.1046.11.1.1.1.1.14=4500, 1.3.6.1.4.1.1046.11.1.1.1.1.15=30, 1.3.6.1.4.1.1046.11.1.1.1.1.16=30000, 1.3.6.1.4.1.1046.11.1.1.1.1.17=20001, 1.3.6.1.4.1.1046.11.1.1.1.1.18=4688211, 1.3.6.1.4.1.1046.11.1.1.1.1.19=0, 1.3.6.1.4.1.1046.11.1.1.1.1.20=0, 1.3.6.1.4.1.1046.11.1.1.1.1.21=0, 1.3.6.1.4.1.1046.11.1.1.1.1.22=0000000, 1.3.6.1.4.1.1046.11.1.1.1.1.23=LABCAPMP4, 1.3.6.1.4.1.1046.11.1.1.1.1.24=HLNH, 1.3.6.1.4.1.1046.11.1.1.1.1.25=, 1.3.6.1.4.1.1046.11.1.1.1.1.26=LabTest30_n, 1.3.6.1.4.1.1046.11.1.1.1.1.27=Preroll, 1.3.6.1.4.1.1046.11.1.1.1.1.28=:
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i need to break these values into two fields &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.1=2&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;first field &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.*&lt;/CODE&gt;  the last decimal  will be 1-28 i also want to replace this with the description of the code&lt;BR /&gt;
so &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.1&lt;/CODE&gt; would be Version&lt;BR /&gt;
&lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.2&lt;/CODE&gt; would be Box&lt;BR /&gt;
&lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.3&lt;/CODE&gt; would be Port etc. &lt;/P&gt;

&lt;P&gt;second field  &lt;CODE&gt;=2&lt;/CODE&gt; i need the part after &lt;CODE&gt;=&lt;/CODE&gt;. this will be numerical value or a name so it could be a &lt;CODE&gt;1,2,3etc&lt;/CODE&gt; or it could read something like &lt;CODE&gt;Preroll&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 15:19:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216497#M63535</guid>
      <dc:creator>rwiley</dc:creator>
      <dc:date>2016-11-10T15:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a numerical field and rename the value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216498#M63536</link>
      <description>&lt;P&gt;If you can get ahold of the MIB you might be able to create a lookup table and match up those values with the text of the MIB.&lt;/P&gt;

&lt;P&gt;Something like this:&lt;/P&gt;

&lt;P&gt;OID,name&lt;BR /&gt;
1.3.6.1.4.1.1046.11.1.1.1.1.1, Version&lt;BR /&gt;
1.3.6.1.4.1.1046.11.1.1.1.1.2, Box&lt;BR /&gt;
1.3.6.1.4.1.1046.11.1.1.1.1.3, Port&lt;/P&gt;

&lt;P&gt;Although looking at the data is splunk extracting each OID as a separate field?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 01:41:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216498#M63536</guid>
      <dc:creator>niemesrw</dc:creator>
      <dc:date>2016-11-11T01:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a numerical field and rename the value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216499#M63537</link>
      <description>&lt;P&gt;Firstly, to match each of the &lt;CODE&gt;*.1&lt;/CODE&gt; as &lt;CODE&gt;Version&lt;/CODE&gt;, &lt;CODE&gt;*.2&lt;/CODE&gt; as &lt;CODE&gt;Box&lt;/CODE&gt; and &lt;CODE&gt;*.3&lt;/CODE&gt; as &lt;CODE&gt;Port&lt;/CODE&gt; you will require a lookup table which in this case I will call as  &lt;CODE&gt;idLookup.csv&lt;/CODE&gt; and its lookup definition I will call as &lt;CODE&gt;idLookup_def&lt;/CODE&gt;. &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/PivotTutorial/AddlookupfilestoSplunk#Find_the_Lookups_manager"&gt;See here on how to create a lookup table and lookup definition&lt;/A&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;suffix,description
1,Version
2,Box
3,Port
:
:
28,DescriptionValueFor28
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once the lookup table and lookup definition is done, we will need the search part which will extract the data from your events and will lookup the data against the description.&lt;/P&gt;

&lt;P&gt;Your data has key value pairs where there are no corresponding values for a particular key after &lt;CODE&gt;=&lt;/CODE&gt;, for example&lt;BR /&gt;
&lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.25=,&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;To handle such values first I have rexed/sed a value &lt;CODE&gt;NA&lt;/CODE&gt; to make them &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.25=NA,&lt;/CODE&gt;. After that you can take the values out in three fields called &lt;CODE&gt;stringPrefix&lt;/CODE&gt;,  &lt;CODE&gt;stringSuffix&lt;/CODE&gt; and &lt;CODE&gt;stringValue&lt;/CODE&gt;. such that for the kv pairs in your data like &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.23=LABCAPMP4&lt;/CODE&gt; or &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.25=NA&lt;/CODE&gt; will end up with string fields as follows:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;stringPrefix&lt;/CODE&gt; with value &lt;CODE&gt;1.3.6.1.4.1.1046.11.1.1.1.1.&lt;/CODE&gt;&lt;BR /&gt;
&lt;CODE&gt;stringSuffix&lt;/CODE&gt; with value &lt;CODE&gt;23&lt;/CODE&gt; or &lt;CODE&gt;25&lt;/CODE&gt;...&lt;BR /&gt;
&lt;CODE&gt;stringValue&lt;/CODE&gt; with value &lt;CODE&gt;LABCAPMP4&lt;/CODE&gt; or &lt;CODE&gt;NA&lt;/CODE&gt;...and so on.&lt;/P&gt;

&lt;P&gt;Once you have these three strings for each of the 28 key value pair from your data then we can match the &lt;CODE&gt;stringSuffix&lt;/CODE&gt; with your &lt;CODE&gt;suffix&lt;/CODE&gt; field in the lookup definition using &lt;CODE&gt;| lookup&lt;/CODE&gt; &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Lookup#Example_1:"&gt;command&lt;/A&gt; and get the description saved in &lt;CODE&gt;idLookup.csv&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Below is then the complete query that should achieve the result you seek:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to get the events
| rex field=_raw mode=sed "s/=,/=NA,/g"
| rex field=_raw max_match=0 "(?&amp;lt;sP&amp;gt;(\d+\.)+)(?&amp;lt;sS&amp;gt;\d+)=(?&amp;lt;sV&amp;gt;[^,]+)"
| eval tempString=mvzip(sP, (mvzip (sS, sV, "~")), "~")
| mvexpand tempString
| rex field=tempString "(?&amp;lt;stringPrefix&amp;gt;[^~]+)~(?&amp;lt;stringSuffix&amp;gt;[^~]+)~(?&amp;lt;stringValue&amp;gt;(.*))"
| eval myString=stringPrefix."".stringSuffix
| lookup idLookup_def suffix as stringSuffix OUTPUT description as description
| table stringPrefix, stringSuffix, myString, description, stringValue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 04:14:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216499#M63537</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-11T04:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract a numerical field and rename the value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216500#M63538</link>
      <description>&lt;P&gt;worked perfectly. i had the lookup but i wasn't sure how to break it down correctly. much thanks!!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2016 14:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-a-numerical-field-and-rename-the-value/m-p/216500#M63538</guid>
      <dc:creator>rwiley</dc:creator>
      <dc:date>2016-11-11T14:18:54Z</dc:date>
    </item>
  </channel>
</rss>

