<?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: Finding last event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83562#M21293</link>
    <description>&lt;P&gt;This isn't exactly what you're asking for, but it may be a starting point.  You can use &lt;CODE&gt;dedup&lt;/CODE&gt; to get the most recent "AV Definition" log event.  And, from there, you can use &lt;CODE&gt;addinfo&lt;/CODE&gt; to add the current time (of the search) to the search.  Using these, you may be able to perform a search that gives you in effect "How long, from now, has it been since this system reported its AV definition number?"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;AV definition | addinfo | dedup 1 host sortby -_time
| eval deltatime=((info_search_time-_time)/3600)
| where deltatime &amp;gt; 24
| table _time,host,deltatime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Apr 2011 20:12:53 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2011-04-18T20:12:53Z</dc:date>
    <item>
      <title>Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83558#M21289</link>
      <description>&lt;P&gt;What is the best (the most efficient) way of finding last (the most recent) events for certain hosts?&lt;/P&gt;

&lt;P&gt;For example, I have a log in which multiple hosts log their AV definition number. I want to compare this with something else so I just need the most recent log per each server.&lt;/P&gt;

&lt;P&gt;Currently I can do this by creating transactions for hosts and then using mvcount and mvindex to extract the most recent value, but this sounds awfully inefficient to me. Is there a better way to do this? (the map command sounds perfect but I've never been able to get it to work ..).&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2011 19:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83558#M21289</guid>
      <dc:creator>bojanz</dc:creator>
      <dc:date>2011-04-18T19:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83559#M21290</link>
      <description>&lt;P&gt;From &lt;A href="http://splunk-base.splunk.com/answers/13930/quickly-find-the-time-since-the-last-event-logged-by-a-host"&gt;quickly-find-the-time-since-the-last-event-logged-by-a-host&lt;/A&gt;, I use&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;| metadata type=hosts | sort recentTime desc | convert ctime(recentTime) as Recent_Time&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 18 Apr 2011 19:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83559#M21290</guid>
      <dc:creator>mslvrstn</dc:creator>
      <dc:date>2011-04-18T19:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83560#M21291</link>
      <description>&lt;P&gt;Assuming you have fields extracted, have you tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YourSearch | stats first(DefNumber) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First will grab the first log that Splunk finds, which should always the most recent event, in this scenario.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2011 19:51:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83560#M21291</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2011-04-18T19:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83561#M21292</link>
      <description>&lt;P&gt;If you just want the events, vs a table of extracted fields (or if you need multiple fields), you can use &lt;CODE&gt;YourSearch | dedup host&lt;/CODE&gt;, and if you know how many hosts you have, you might be able to make it finish faster with: &lt;CODE&gt;YourSearch | dedup host | head X&lt;/CODE&gt;, where X is the number of hosts you want to see.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2011 20:12:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83561#M21292</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-04-18T20:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83562#M21293</link>
      <description>&lt;P&gt;This isn't exactly what you're asking for, but it may be a starting point.  You can use &lt;CODE&gt;dedup&lt;/CODE&gt; to get the most recent "AV Definition" log event.  And, from there, you can use &lt;CODE&gt;addinfo&lt;/CODE&gt; to add the current time (of the search) to the search.  Using these, you may be able to perform a search that gives you in effect "How long, from now, has it been since this system reported its AV definition number?"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;AV definition | addinfo | dedup 1 host sortby -_time
| eval deltatime=((info_search_time-_time)/3600)
| where deltatime &amp;gt; 24
| table _time,host,deltatime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Apr 2011 20:12:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83562#M21293</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-04-18T20:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83563#M21294</link>
      <description>&lt;P&gt;Thanks, that should do it for this case &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2011 20:16:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83563#M21294</guid>
      <dc:creator>bojanz</dc:creator>
      <dc:date>2011-04-18T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83564#M21295</link>
      <description>&lt;P&gt;Very nice!  Created a multiple process monitor like &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
index=os sourcetype=ps host=dcagsm*&lt;BR /&gt;&lt;BR /&gt;
|  eval gsa_is_running=if(match(_raw, "GSA"), "GSA Running", "GSA Not Running") &lt;BR /&gt;
|  eval GSC_is_running=if(match(_raw, "GSC"), "GSC Running", "GSC Not Running") &lt;BR /&gt;
|  eval GSM_is_running=if(match(_raw, "GSM"), "GSM Running", "GSM Not Running") &lt;BR /&gt;
|  eval LH_is_running=if(match(_raw, "LH"), "LH Running", "LH Not Running") &lt;BR /&gt;
| stats first(gsa_is_running) as GSA,&lt;BR /&gt;
first(GSC_is_running) as GSC,&lt;BR /&gt;
first(GSM_is_running) as GSM,&lt;BR /&gt;
first(LH_is_running) as LH, by host&lt;BR /&gt;
| search "Not Running"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:38:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83564#M21295</guid>
      <dc:creator>primenetadmin</dc:creator>
      <dc:date>2020-09-28T13:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83565#M21296</link>
      <description>&lt;P&gt;dedup is inefficient because it searches every event from every host (all indexes/sourcetypes available) until you tell it to stop.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2014 16:33:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83565#M21296</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2014-11-21T16:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Finding last event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83566#M21297</link>
      <description>&lt;P&gt;Expanding the timeframe of such a search increases its "cost" - its time to run. I.e. Splunk does not stop searching when it finds the most recent event - it keeps going through all of them. This doesn't feel efficient to me.&lt;/P&gt;

&lt;P&gt;Why this matters: if the task is get the value of a field in the &lt;STRONG&gt;last&lt;/STRONG&gt; event in a search no matter when that last event happened (30 seconds ago? Two years?) - one should search "all time", and this will take a long, long time to complete across a decent size dataset. If on the other hand &lt;CODE&gt;stats first&lt;/CODE&gt; could stop searching once it found the last event - that would dramatically decrease the cost.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 00:10:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Finding-last-event/m-p/83566#M21297</guid>
      <dc:creator>mitag</dc:creator>
      <dc:date>2020-05-07T00:10:05Z</dc:date>
    </item>
  </channel>
</rss>

