<?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: Extracting field based on prior field extracted in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273773#M82585</link>
    <description>&lt;P&gt;Can you share your search as is?&lt;/P&gt;</description>
    <pubDate>Thu, 15 Oct 2015 15:58:41 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2015-10-15T15:58:41Z</dc:date>
    <item>
      <title>Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273771#M82583</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;So I have data that looks something like this where each event contains somewhat historical data, and it has multiple fields that are similar to each other.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**Event 1**
Serial: xxxxxxxxx
BU1 - 84.5xx.x
#############################
  Serial: xxxxxxxxx
BU2- 83.5xx.x
#############################
 Serial: xxxxxxxxx
BU3- 83.6xx.x
#############################
 Serial: xxxxxxxxx
BU4- 85.xxx.x
#############################
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically I'm running a rex command that extracts all the BU's and displays the largest value within the event as &lt;STRONG&gt;largest_BU&lt;/STRONG&gt; (I.E Rex extraction command then max value for those values), however I cannot use that same logic in extracting the serial, so I was thinking that maybe I could correlate the extraction of the serial to the BU because ultimately I want to keep the largest BU and corresponding serial together in different fields. Is this possible, or might there be another way to approach this?&lt;BR /&gt;
Thank you for all the help, and let me know if more information is needed.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 15:36:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273771#M82583</guid>
      <dc:creator>raby1996</dc:creator>
      <dc:date>2015-10-15T15:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273772#M82584</link>
      <description>&lt;P&gt;Perhaps you could try something like last, latest, first, &amp;amp; earliest...&lt;/P&gt;

&lt;P&gt;You might also be interested in making serial and BU multi valued with makemv, and other "mv" commands.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 15:58:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273772#M82584</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-10-15T15:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273773#M82585</link>
      <description>&lt;P&gt;Can you share your search as is?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 15:58:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273773#M82585</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2015-10-15T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273774#M82586</link>
      <description>&lt;P&gt;Yes it looks similar to this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search "relevant info"
| rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Bu&amp;gt;(?:3[6]+\.\d+\.\d+\.\d+))"  
| eval largest_BU=max(Bu)
| rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Serial&amp;gt;(\s+\d+\-\d+\S\S+))" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where I need the Serial to correspond to the largest_BU.&lt;BR /&gt;
Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 16:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273774#M82586</guid>
      <dc:creator>raby1996</dc:creator>
      <dc:date>2015-10-15T16:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273775#M82587</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search "relevant info"
 | rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Bu&amp;gt;(?:3[6]+\.\d+\.\d+\.\d+))"  
 | rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Serial&amp;gt;(\s+\d+\-\d+\S\S+))" 
 | eval largest_BU=max(Bu)
 | eval temp=mvzip(Bu,Serial,"##") 
 | eval SerialForLargest_BU=replace(mvfilter(match(temp,largest_BU."##")),"(.*)##.*","\1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Update:&lt;BR /&gt;
I tested above and the regular exp for match doesn't take field as input. So try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search "relevant info"
     | rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Bu&amp;gt;(?:3[6]+\.\d+\.\d+\.\d+))"  
     | rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Serial&amp;gt;(\s+\d+\-\d+\S\S+))" 
     | eval temp=mvzip(Bu,Serial,"##") 
     | eval temp=mvsort(temp)
     | eval temp=mvindex(temp,-1)
     | rex field=temp "(?&amp;lt;largest_BU&amp;gt;.*)##(?&amp;lt;SerialForLargestBU&amp;gt;.*)" 
     | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2015 16:17:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273775#M82587</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-10-15T16:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273776#M82588</link>
      <description>&lt;P&gt;Hmm, I can't seem to get the last part of the search to work " arguments to mvfilter are invalid" is what I'm getting.&lt;BR /&gt;
here is the actual search I'm using, where I switched the values of ## to the actual delimiter i want to use,  however I feel like I'm not understanding how the last command works, so I might be using it wrong &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | search "relevant information"
    | rex max_match=0 "(?:\n|.)\s+(?&amp;lt;Bu&amp;gt;(?:8[7]+\.\d+\.\d+\.\d+))"  
    | rex max_match=0 "((?:\n|.)*?MTMS:(?&amp;lt;Serial&amp;gt;\s+\d+\-\d+\S\S+))"
    | eval Bundle=max(Bu)
    | eval temp=mvzip(Bu,Serial,"MTMS")
    | eval SerialForLargest_BU=replace(mvfilter(match(temp,Bundle."MTMS")),"(.*)MTMS.*","\1")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Oct 2015 17:02:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273776#M82588</guid>
      <dc:creator>raby1996</dc:creator>
      <dc:date>2015-10-15T17:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting field based on prior field extracted</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273777#M82589</link>
      <description>&lt;P&gt;This seems to work with a limited set of test data.  But it's also late, so it could be way off too &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Essentially, I'm trying split the event by the hashtags, and then expand those sections into separate events.  So instead of 1 event above, you'd have 4.  And then I rex the serial and bu for each of those new events (so each section of the original 1 event).  Then across all events, i do a stats for the largest bu by _raw (even after the expand, all of those new events still have the same _raw). &lt;/P&gt;

&lt;P&gt;So now each event has a _raw, serial, bu and the max(bu) that represents the highest bu across the same original event.  So finally, I filter on where the max field is the same as the bu field, since those will only match for those events that represent the largest bu per _raw.  And that's it, just table the remaining serial and bu fields.  &lt;/P&gt;

&lt;P&gt;Hopefully that makes sense (and is logically correct)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype="test:serial" 
| eval blah = _raw 
| makemv blah delim="#############################" 
| mvexpand blah 
| rex field=blah "Serial:\s+(?&amp;lt;serial&amp;gt;\S+)[^-]+-(?&amp;lt;bu&amp;gt;.+)" 
| eventstats max(bu) as max by _raw 
| where max=bu 
| table serial bu
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Oct 2015 02:36:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-field-based-on-prior-field-extracted/m-p/273777#M82589</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2015-10-16T02:36:23Z</dc:date>
    </item>
  </channel>
</rss>

