<?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 display the latest event as a result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462790#M130504</link>
    <description>&lt;P&gt;Use the second one I just listed for all destinations. If you want the status for each combination of src port and destination, you already had that in your image link. Note that your destinations were different which is why there were 2 states. The destinations are so similar perhaps you thought they were the same?&lt;/P&gt;</description>
    <pubDate>Mon, 21 Oct 2019 07:22:03 GMT</pubDate>
    <dc:creator>moliminous</dc:creator>
    <dc:date>2019-10-21T07:22:03Z</dc:date>
    <item>
      <title>How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462771#M130485</link>
      <description>&lt;P&gt;Search query :1&lt;BR /&gt;
index="main"  earliest=06/01/2019:00:00:00 latest=now | stats  first(status) by src destination port&lt;BR /&gt;
Search query : 2&lt;BR /&gt;
index="main"  earliest=06/01/2019:00:00:00 latest=now | stats  latest(status) by src destination port&lt;BR /&gt;
I have used first and latest command in stats. &lt;/P&gt;

&lt;P&gt;There 2 status in the events like "STATE UP" and "STATE DOWN". I would like fetch the latest event with latest status field. But if i am searching the above query it is showing the both.(STATE UP and STATE DOWN). I would like display the latest either "status up or status down".&lt;BR /&gt;
Someone help me to find the solution.&lt;BR /&gt;
Current Results:&lt;BR /&gt;
src     destination     port    first(status)&lt;BR /&gt;
XXX         YYY                443       State DOWN&lt;BR /&gt;
XXX         YYY                 443      State UP&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 12:25:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462771#M130485</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-17T12:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462772#M130486</link>
      <description>&lt;P&gt;Query 2 is the one you want, and it works fine for me in 7.2.4&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;          | makeresults | eval _time = now()-1, src="XXX", destination="YYY", port=443, status="DOWN"
| append [| makeresults | eval _time = now()  , src="XXX", destination="YYY", port=443, status="UP" ]
| stats latest(status) by src destination port

src   destination   port   latest(status)
XXX   YYY           443    UP
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;edit: Unless your timestamp on both rows is the exact same? Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats latest(status) by _time src destination port
| sort -_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:19:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462772#M130486</guid>
      <dc:creator>jacobpevans</dc:creator>
      <dc:date>2019-10-17T13:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462773#M130487</link>
      <description>&lt;P&gt;Hi Jacobevans,&lt;BR /&gt;
Thank you for the query. But i am expecting the different results. In netscaler, The events will trigger when there is a status change from UP to DOWN or DOWN to UP. I would like to display the latest status with respect to source and destination. You query gives all the results which is not expected one&lt;/P&gt;

&lt;P&gt;Example : I have 3 events&lt;BR /&gt;
10/17/19 7:05 PM : Status was DOWN&lt;BR /&gt;
10/17/19 7:06 PM : Status was UP&lt;BR /&gt;
10/17/19 7:07 PM : Status was DOWN&lt;/P&gt;

&lt;P&gt;expected out put should be the current status, Like below:&lt;BR /&gt;
STATE was DOWN(Because this status is the latest)&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:39:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462773#M130487</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-17T13:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462774#M130488</link>
      <description>&lt;P&gt;The way to get the most recent status would be to end your query with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats latest(status) by src destination port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you wish to also see the time of the event in the results you would add it as a value rather than split the stats command by _time, to avoid seeing every entry for that src/dest/port combo, by adding this to the end of your query instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats values(_time) as _time, latest(status) by src destination port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If either of these result in more than one status, there is something else wrong with the values that are in src, destination, and/or port. The only ways you would see more than 1 status for these is if:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;'status' field has multiple values per event (perhaps due to commands earlier in your search&lt;/LI&gt;
&lt;LI&gt;The values are unique between src, destination, port&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;You can test if the 'status' field has multiple values using this command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval n = mvcount(status)
| where n&amp;gt;1
| sort - n
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would also note that 'destination' is not a CIM-compliant field, it should be normalized to just 'dest' using an alias or other method.&lt;/P&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 03:46:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462774#M130488</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-18T03:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462775#M130489</link>
      <description>&lt;P&gt;Hi moliminous,&lt;BR /&gt;
I have used your query but still i am getting both values like state up and state down for each src and destination.&lt;BR /&gt;
But i need the latest event field value.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 05:47:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462775#M130489</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-18T05:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462776#M130490</link>
      <description>&lt;P&gt;Status field has only one value(either "STATE UP" or STATE DOWN"  in each event.&lt;BR /&gt;
Values are unique between src destination and port&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 09:57:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462776#M130490</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-18T09:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462777#M130491</link>
      <description>&lt;P&gt;The only way that is possible is something else is wrong with either the data or your environment. Please post your entire SPL and a screenshot of results. &lt;BR /&gt;
As I mentioned, either the values aren’t actually unique or there are many events at once and an issue with duplicate events on your indexers. &lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 10:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462777#M130491</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-18T10:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462778#M130492</link>
      <description>&lt;P&gt;Under normal circumstances those 2 searches should return the same results.  Occasionally, you will see a warning that says something like &lt;CODE&gt;There was a problem and your search results might not be returned in time sorted order&lt;/CODE&gt; or some such, and in that case, they will differ.  You should stick with using &lt;CODE&gt;first(status)&lt;/CODE&gt; presuming you have not re-sorted your events (they are returned in latest-to-oldest order with latest on top, e.g. "first"), because it is more efficient.  What do you get with these?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" earliest=06/01/2019:00:00:00 latest=now | sort 0 - _time | stats first(status)    BY src destination port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;vs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="main" earliest=06/01/2019:00:00:00 latest=now | sort 0 - _time | stats latest(status) BY src destination port
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These should absolutely be the same.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 19:21:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462778#M130492</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-18T19:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462779#M130493</link>
      <description>&lt;P&gt;I respectfully disagree. Though first(stats) is faster, it doesn’t guarantee the latest event chronologically, which is what the goal is here. First is faster because it doesn’t wait for the entire set of results, it will return the first event that streams in. Although that is often the most recent, it isn’t necessarily the most recent. &lt;/P&gt;</description>
      <pubDate>Sat, 19 Oct 2019 01:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462779#M130493</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-19T01:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462780#M130494</link>
      <description>&lt;P&gt;Hi Moliminous,&lt;BR /&gt;
Please find the below link of entire search result.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://ibb.co/cbRGzyw"&gt;https://ibb.co/cbRGzyw&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:09:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462780#M130494</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-21T06:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462781#M130495</link>
      <description>&lt;P&gt;Hi Woodcock,&lt;/P&gt;

&lt;P&gt;I am getting the same result even if i include sort command. Please find the below url of entire search.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://ibb.co/cbRGzyw"&gt;https://ibb.co/cbRGzyw&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462781#M130495</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-21T06:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462782#M130496</link>
      <description>&lt;P&gt;I don’t see an issue in your image. The destinations are unique so that search shows the result of latest state per src dest combination. If that’s not what you wanted please list what you’d like to display instead. &lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462782#M130496</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-21T06:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462783#M130497</link>
      <description>&lt;P&gt;Dest is MPGDR vs MPGPR&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:34:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462783#M130497</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-21T06:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462784#M130498</link>
      <description>&lt;P&gt;if you see the image STATE UP and STATE DOWN status are showing in it. I would like display the single row with current status(Either STATE UP or STATE DOWN not the both)&lt;BR /&gt;
for all source and destination&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:36:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462784#M130498</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-21T06:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462785#M130499</link>
      <description>&lt;P&gt;I would like to display the current status(either state up or state down) with respect to src destination and port&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:37:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462785#M130499</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-21T06:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462786#M130500</link>
      <description>&lt;P&gt;Okay so you don’t want to split by destination then. Move destination to before the ‘by’ clause and use either latest(destination) or values(destination) if you want the whole list for that src and port. If you put destination after the BY clause, Splunk shows every unique combination of the fields after BY. &lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:42:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462786#M130500</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-21T06:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462787#M130501</link>
      <description>&lt;P&gt;can you please modify the query and paste it.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:45:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462787#M130501</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-21T06:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462788#M130502</link>
      <description>&lt;P&gt;| stats latest(destination) as destination, latest(status) as status, by src port&lt;/P&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;P&gt;| stats values(destination) as destination, latest(status) as status by src port&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 06:51:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462788#M130502</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-21T06:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462789#M130503</link>
      <description>&lt;P&gt;It is working as partial. &lt;STRONG&gt;I would like to display all the source and destination with respect to status(Either STATE UP or STATE DOWN&lt;/STRONG&gt;.&lt;BR /&gt;
Your query display the latest destination (Ignoring some destination).&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 07:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462789#M130503</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2019-10-21T07:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to display the latest event as a result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462790#M130504</link>
      <description>&lt;P&gt;Use the second one I just listed for all destinations. If you want the status for each combination of src port and destination, you already had that in your image link. Note that your destinations were different which is why there were 2 states. The destinations are so similar perhaps you thought they were the same?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 07:22:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-the-latest-event-as-a-result/m-p/462790#M130504</guid>
      <dc:creator>moliminous</dc:creator>
      <dc:date>2019-10-21T07:22:03Z</dc:date>
    </item>
  </channel>
</rss>

