<?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: Last Value in Lookup as Variable? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122918#M33176</link>
    <description>&lt;P&gt;Thanks. I was storing value as text KER0000123 so we could use it in our knowledgebase and ticketing system as a keyword. Will try storing as a number too and see if that works.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Apr 2014 14:19:45 GMT</pubDate>
    <dc:creator>snoobzilla</dc:creator>
    <dc:date>2014-04-08T14:19:45Z</dc:date>
    <item>
      <title>Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122916#M33174</link>
      <description>&lt;P&gt;How do I get the last KER out of my lookup and get it into search below as LASTKER?&lt;/P&gt;

&lt;P&gt;I have a lookup table of error signatures. I have assigned a KER0000### e.g KER0000123 as a primary key to use when referencing the signature... I want to auto increment new signatures. If I run this &lt;/P&gt;

&lt;P&gt;search error&lt;BR /&gt;
| stats count by &lt;EM&gt;fields used for signature&lt;/EM&gt;&lt;BR /&gt;
| eval LASTKER="KER0000100"&lt;BR /&gt;
| where count &amp;gt;10 &lt;BR /&gt;
| streamstats count(KER) AS INCREMNT &lt;BR /&gt;
| eval myint=ltrim(LASTKER, "KER")&lt;BR /&gt;
| eval  myint=INCREMNT+myint &lt;BR /&gt;
| eval myint="0000000".myint &lt;BR /&gt;
| rex field=myint "(?&lt;MYINT&gt;\d{7})$" &lt;BR /&gt;
| eval KER="KER".myint&lt;/MYINT&gt;&lt;/P&gt;

&lt;P&gt;Above gives expected results based on KER0000100 (e.g. next one is KER0000101, then KER0000102...)&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2014 22:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122916#M33174</guid>
      <dc:creator>snoobzilla</dc:creator>
      <dc:date>2014-04-07T22:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122917#M33175</link>
      <description>&lt;P&gt;Here's what you can do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval [inputlookup cim_http_status_lookup | sort - status | head 1 | return status] | eval new_status = status + 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm using a lookup of HTTP status codes as an example, available in the Splunk Common Information Model: &lt;A href="http://apps.splunk.com/app/1621/"&gt;http://apps.splunk.com/app/1621/&lt;/A&gt;&lt;BR /&gt;
That gives me my "previous values", I sort them by some criterion and pick one row, one field to return, yielding a string of &lt;CODE&gt;status="511"&lt;/CODE&gt; that gets passed to the &lt;CODE&gt;eval&lt;/CODE&gt; and added to my dummy event generated by &lt;CODE&gt;| stats count&lt;/CODE&gt;.&lt;BR /&gt;
After that I can do any math I like, such as incrementing.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 14:10:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122917#M33175</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-08T14:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122918#M33176</link>
      <description>&lt;P&gt;Thanks. I was storing value as text KER0000123 so we could use it in our knowledgebase and ticketing system as a keyword. Will try storing as a number too and see if that works.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 14:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122918#M33176</guid>
      <dc:creator>snoobzilla</dc:creator>
      <dc:date>2014-04-08T14:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122919#M33177</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;H2&gt;Updated:&lt;/H2&gt;

&lt;PRE&gt;&lt;CODE&gt;search error | stats count by fields used for signature | where count &amp;gt;10 | eval joinfield=1
| join joinfield [|inputlookup error_signature.csv | rex field=KER "KER(?&amp;lt;counter&amp;gt;.*)" 
| eval counter=tonumber(counter) | stats max(counter) as LASTKER | eval joinfield=1]
| fields - joinfield | streamstats count(KER) AS INCREMNT  
| eval myint=INCREMNT+LASTKER| eval myint="0000000".myint 
| rex field=myint "(?&amp;lt;myint&amp;gt;\d{7})$" | eval KER="KER".myint
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Apr 2014 15:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122919#M33177</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-08T15:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122920#M33178</link>
      <description>&lt;P&gt;My numbers are just an example - you can use your combo of &lt;CODE&gt;ltrim(...)&lt;/CODE&gt; if you like. Just replace the fixed &lt;CODE&gt;LASTKER="KER00000100"&lt;/CODE&gt; with a subsearch yielding that field.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 15:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122920#M33178</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-08T15:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122921#M33179</link>
      <description>&lt;P&gt;I tried that and unfortunately I am only getting 1 row of KER back even when I have multiple new signatures.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 18:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122921#M33179</guid>
      <dc:creator>snoobzilla</dc:creator>
      <dc:date>2014-04-08T18:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122922#M33180</link>
      <description>&lt;P&gt;My bad, I overlooked that completely. Try the updated answer.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 19:36:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122922#M33180</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-08T19:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122923#M33181</link>
      <description>&lt;P&gt;Thank you, that did the trick!!!!!!!!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 20:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122923#M33181</guid>
      <dc:creator>snoobzilla</dc:creator>
      <dc:date>2014-04-08T20:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Last Value in Lookup as Variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122924#M33182</link>
      <description>&lt;P&gt;One typo... missing \ before d. Last line should read &lt;BR /&gt;
| rex field=myint "(?&lt;MYINT&gt;\d{7})$" | eval KER="KER".myint&lt;/MYINT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 20:19:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Last-Value-in-Lookup-as-Variable/m-p/122924#M33182</guid>
      <dc:creator>snoobzilla</dc:creator>
      <dc:date>2014-04-08T20:19:19Z</dc:date>
    </item>
  </channel>
</rss>

