<?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 show only the two most recent events in a table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29550#M177955</link>
    <description>&lt;P&gt;Let me see if I get it -- so you want to see 2 events for each host+port combination, unless they're on different days in which case you only want to show the most recent of the two dates?&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jan 2011 07:20:38 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2011-01-21T07:20:38Z</dc:date>
    <item>
      <title>How do I show only the two most recent events in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29547#M177952</link>
      <description>&lt;P&gt;Let's say I have a table that looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date        Host       Port
1/1/2011    HostA      80
1/2/2011    HostA      80
1/3/2011    HostA      80
1/1/2011    HostB      443
1/2/2011    HostB      443
1/3/2011    HostB      443
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I filter my table so that only the two most recent events for each host/port combination is displayed?&lt;/P&gt;

&lt;P&gt;Thx.&lt;/P&gt;

&lt;P&gt;Craig&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2011 12:59:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29547#M177952</guid>
      <dc:creator>jambajuice</dc:creator>
      <dc:date>2011-01-20T12:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show only the two most recent events in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29548#M177953</link>
      <description>&lt;P&gt;All you need is this on the end of your search: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt;  | dedup 2 Host Port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Usually dedup only keeps the last row for each value, but you can tell it to keep the last N rows instead. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Dedup" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Dedup&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2011 15:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29548#M177953</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-01-20T15:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show only the two most recent events in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29549#M177954</link>
      <description>&lt;P&gt;What about if I only want to see events from the 1/3/2011 date?  I've tried dedup 1 host date, but I'm seeing one record from each date rather than all results from the most recent date.&lt;/P&gt;

&lt;P&gt;Thanks for your help!!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2011 05:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29549#M177954</guid>
      <dc:creator>jambajuice</dc:creator>
      <dc:date>2011-01-21T05:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show only the two most recent events in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29550#M177955</link>
      <description>&lt;P&gt;Let me see if I get it -- so you want to see 2 events for each host+port combination, unless they're on different days in which case you only want to show the most recent of the two dates?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2011 07:20:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29550#M177955</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-01-21T07:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show only the two most recent events in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29551#M177956</link>
      <description>&lt;P&gt;It actually sounds like in your comment you're asking an entirely different question which is a bit confusing.   And the answer to the second question is just "use the time controls to restrict your search to just that one date"?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2011 02:47:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29551#M177956</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-01-24T02:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show only the two most recent events in a table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29552#M177957</link>
      <description>&lt;P&gt;I may be looking for a similar thing. I want to retrieve all events that match the date/time of the most recent event (because I have an audit script that runs monthly with two fields - Test and Count - and if there is a zero result for a test (the tests may change over time) then it isn't logged:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;2012-01-18T22:00:00Z Valid 500&lt;BR /&gt;
2012-01-18T22:00:00Z Fail-Pwd 3&lt;BR /&gt;
2012-01-18T22:00:00Z Fail-NoMgr 45&lt;BR /&gt;
2012-01-18T22:00:00Z Fail-NoExpire 7&lt;BR /&gt;
2012-01-18T22:00:00Z Pass 1445&lt;BR /&gt;
2012-02-22T22:25:15Z Valid 500&lt;BR /&gt;
2012-02-22T22:25:15Z Fail-NoMgr 45&lt;BR /&gt;
2012-02-22T22:25:15Z Fail-NoExpire 7&lt;BR /&gt;
2012-02-22T22:25:15Z Pass 1448&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Dedup will return a result from last month if there was a zero result this month (in my case, the "Fail-Pwd 3" event), so I use the following:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="MyIndex" sourcetype="MySourcetype" [metadata index=MyIndex type=sourcetypes  | where sourcetype="MySourcetype" | eval earliest = lastTime | fields earliest]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This gives me every event with a timestamp that's the same as the most recent event.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2012 00:39:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-only-the-two-most-recent-events-in-a-table/m-p/29552#M177957</guid>
      <dc:creator>FunPolice</dc:creator>
      <dc:date>2012-02-23T00:39:46Z</dc:date>
    </item>
  </channel>
</rss>

