<?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 the latest event for a sourcetype? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169258#M48357</link>
    <description>&lt;P&gt;This search is &lt;EM&gt;extremely&lt;/EM&gt; fast, and can give you basic info about sourcetypes&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=sourcetypes index=euc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also run this search with &lt;CODE&gt;type=hosts&lt;/CODE&gt; and &lt;CODE&gt;type=sources&lt;/CODE&gt;. You could create a dashboard with 3 panels and have one search in each panel. The &lt;CODE&gt;recentTime&lt;/CODE&gt; in the result is the latest time that Splunk indexed data from that sourcetype (or host or source). The &lt;CODE&gt;lastTime&lt;/CODE&gt; is the timestamp of the most recent event. In large environments, the metadata command might not be completely accurate, though. This command will look back as many days as it can.&lt;/P&gt;

&lt;P&gt;For the complete listing (which you could use the check the accuracy of the above technique), I would do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=euc_
| stats latest(_time) as latestTime by  host sourcetype source
| eval latestTime=strftime(latestTime,"%x %X")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since you are only looking at one index, the metadata command will probably be accurate.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Aug 2015 17:00:37 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2015-08-12T17:00:37Z</dc:date>
    <item>
      <title>How do I show the latest event for a sourcetype?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169257#M48356</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I need to show a customer that their logs are appearing in Splunk, and want to list the host, sourcetype, and source, along with the most recent event (with a nice date)  going back 7 days.  &lt;/P&gt;

&lt;P&gt;I can do most of it, but am having problems with the most recent event per sourcetype.  I have the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=euc_*  host=lyncqa*fe* |fields host, sourcetype, source |dedup host, sourcetype, source |table host, sourcetype, source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone help me?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 14:01:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169257#M48356</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2015-08-12T14:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show the latest event for a sourcetype?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169258#M48357</link>
      <description>&lt;P&gt;This search is &lt;EM&gt;extremely&lt;/EM&gt; fast, and can give you basic info about sourcetypes&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=sourcetypes index=euc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also run this search with &lt;CODE&gt;type=hosts&lt;/CODE&gt; and &lt;CODE&gt;type=sources&lt;/CODE&gt;. You could create a dashboard with 3 panels and have one search in each panel. The &lt;CODE&gt;recentTime&lt;/CODE&gt; in the result is the latest time that Splunk indexed data from that sourcetype (or host or source). The &lt;CODE&gt;lastTime&lt;/CODE&gt; is the timestamp of the most recent event. In large environments, the metadata command might not be completely accurate, though. This command will look back as many days as it can.&lt;/P&gt;

&lt;P&gt;For the complete listing (which you could use the check the accuracy of the above technique), I would do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=euc_
| stats latest(_time) as latestTime by  host sourcetype source
| eval latestTime=strftime(latestTime,"%x %X")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since you are only looking at one index, the metadata command will probably be accurate.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2015 17:00:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169258#M48357</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-08-12T17:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I show the latest event for a sourcetype?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169259#M48358</link>
      <description>&lt;P&gt;tstats might be a faster option as well&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats latest(_time) as last where sourcetype=whatever | convert ctime(last)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Aug 2015 01:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-show-the-latest-event-for-a-sourcetype/m-p/169259#M48358</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2015-08-13T01:06:54Z</dc:date>
    </item>
  </channel>
</rss>

