<?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 to find previous releases using current release? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317360#M166243</link>
    <description>&lt;P&gt;Is there a command to get the second value or 3rd value alone. Not like all last 2 values ?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Sep 2017 06:05:41 GMT</pubDate>
    <dc:creator>sangs8788</dc:creator>
    <dc:date>2017-09-06T06:05:41Z</dc:date>
    <item>
      <title>How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317355#M166238</link>
      <description>&lt;P&gt;Lookup file contains &lt;STRONG&gt;release number&lt;/STRONG&gt; and its &lt;STRONG&gt;start date&lt;/STRONG&gt;. The fields in lookup file are &lt;STRONG&gt;Release&lt;/STRONG&gt; and &lt;STRONG&gt;Production (start date of release)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I have a query  which lists me Release, its time range&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup ReleaseCalender.csv |sort Release ASC  | reverse |streamstats current=f last(Production) as latest|rename Production as earliest|eval timenow=now()| convert mktime(*) timeformat="%d/%m/%Y"| table Release, earliest, latest
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result would look something like below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Release  Earliest      Latest
7.4   1500076800    1504915200
7.3   1494633600    1500076800
7.2   1489795200    1494633600
7.1   1484956800    1489795200
6.6   1478908800    1484956800
6.5   1473465600    1478908800
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am able to get the current release date using timenow() . Below query gives me current release based on current date. Say 7.3&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup ReleaseCalender.csv |sort Release ASC  | reverse |streamstats current=f last(Production) as latest|rename Production as earliest|eval timenow=now()| convert mktime(*) timeformat="%d/%m/%Y"| where earliest=timenow | table Release, earliest, latest
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I fetch the previous release(7.2), 2nd previous release(7.1) or 3rd previous release(6.6) details based on current release query ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 10:22:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317355#M166238</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-09-05T10:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317356#M166239</link>
      <description>&lt;P&gt;The most straightforward way is with &lt;CODE&gt;autoregress&lt;/CODE&gt;:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Autoregress"&gt;https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Autoregress&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317356#M166239</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-09-05T11:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317357#M166240</link>
      <description>&lt;P&gt;How do i get one release number at a time. because with this i see lists 2nd 3rd and 4th all together. Also say above shared query result 7.3 which itself 2nd value in lookup file, i want 2nd, 3rd value after 7.3. How do i get from the selected value ? &lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:39:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317357#M166240</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-09-05T11:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317358#M166241</link>
      <description>&lt;P&gt;@sangs8788, To me the following reverse seems redundant &lt;CODE&gt;|sort Release ASC | reverse&lt;/CODE&gt;, you can use &lt;CODE&gt;|sort - Release&lt;/CODE&gt; instead. &lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 12:32:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317358#M166241</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-05T12:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317359#M166242</link>
      <description>&lt;P&gt;Try the following to your search. I have added an eval case to decide the &lt;CODE&gt;releaseFlag&lt;/CODE&gt; as &lt;CODE&gt;Current&lt;/CODE&gt;, &lt;CODE&gt;Previous&lt;/CODE&gt; or &lt;CODE&gt;Next&lt;/CODE&gt; based on current time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup ReleaseCalender.csv 
| sort Release ASC 
| reverse 
| streamstats current=f last(Production) as latest
| rename Production as earliest
| eval timenow=now()
| eval releaseFlag=case(timenow&amp;gt;latest,"Previous",timenow&amp;lt;=latest AND timenow&amp;gt;earliest,"Current",timenow&amp;lt;earliest,"Future")
| search releaseFlag="Previous"
| fieldformat earliest=strftime(earliest,"%d/%m/%Y")
| fieldformat latest=strftime(latest,"%d/%m/%Y")
| fieldformat timenow=strftime(timenow,"%d/%m/%Y")
| head 2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Based on how many releases you want to pull you can set head command. Above example will pull two previous releases through &lt;CODE&gt;| head 2&lt;/CODE&gt;. If you want to test you can change the timenow to static values for specific release &lt;CODE&gt;| eval timenow=1489795201&lt;/CODE&gt;  etc and remove the &lt;CODE&gt;| head 2&lt;/CODE&gt; pipe.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;[Updated to add fieldformat to format Date field as dd/mm/YYYY]&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 12:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317359#M166242</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-05T12:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317360#M166243</link>
      <description>&lt;P&gt;Is there a command to get the second value or 3rd value alone. Not like all last 2 values ?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 06:05:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317360#M166243</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-09-06T06:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317361#M166244</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Option 1- Using streamstats for counting all iterations&lt;/STRONG&gt;&lt;BR /&gt;
Add the following after the releaseFlag, it will add a counter to each releaseFlag.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count as iteration_counter by releaseFlag reset_on_change=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can then change your search condition to match both releaseFlag and iteration_counter. For example following will get 2nd iteration counter for Previous Release.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search releaseFlag="Previous" AND iteration_counter=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2- Using accum for counting selected iterations&lt;/STRONG&gt;&lt;BR /&gt;
After searching &lt;CODE&gt;Previous&lt;/CODE&gt; releases,  set the counter to 1&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search releaseFlag="Previous" 
| eval iteration_counter=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Use &lt;CODE&gt;accum&lt;/CODE&gt; command to get a cumulative counter&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| accum iteration_counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then filter to specific iteration using search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search iteration_counter=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please check the options and confirm. Kindly up vote if this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 08:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317361#M166244</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-06T08:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to find previous releases using current release?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317362#M166245</link>
      <description>&lt;P&gt;Thanks. This really helped.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 09:28:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-previous-releases-using-current-release/m-p/317362#M166245</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-09-06T09:28:08Z</dc:date>
    </item>
  </channel>
</rss>

