<?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 extract date of the latest event after group by? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440752#M172449</link>
    <description>&lt;P&gt;after your &lt;CODE&gt;|stats count ...&lt;/CODE&gt; you will lose your field DateTime.&lt;BR /&gt;
You can use &lt;CODE&gt;eventstats&lt;/CODE&gt; instead of &lt;CODE&gt;stats&lt;/CODE&gt; which will hold all your fields.&lt;/P&gt;

&lt;P&gt;To make things clear: does your search results all have the same value for &lt;CODE&gt;DateTime&lt;/CODE&gt;? Then you could add &lt;CODE&gt;DateTime&lt;/CODE&gt; to your by clause in your &lt;CODE&gt;stats&lt;/CODE&gt; command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test_mulesoft" sourcetype="SFTP-Highradius" 61c1bf00-45e7-11e9-bb4e-12376871b014 | rex field=_raw "corelationid.:\W+(?.)\"" | stats count as result values(numberOfRequests) as request_id by numberOfRequests DateTime | eval result = if (result==2,"SUCCESS","ERROR REPORTED") | table request_id,result,DateTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Mar 2019 15:36:52 GMT</pubDate>
    <dc:creator>damann</dc:creator>
    <dc:date>2019-03-14T15:36:52Z</dc:date>
    <item>
      <title>How to extract date of the latest event after group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440751#M172448</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;

&lt;P&gt;I am facing issue after using group by clause. (Need date of the grouped event in DD-MM-YYYY )&lt;/P&gt;

&lt;P&gt;The search that I am using is below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test_mulesoft"  sourcetype="SFTP-Highradius" 61c1bf00-45e7-11e9-bb4e-12376871b014 | rex field=_raw "corelationid.*:\W+(?.*)\"" | stats count as result values(numberOfRequests) as request_id by numberOfRequests, | eval result = if (result==2,"SUCCESS","ERROR REPORTED")  | table request_id,result,DateTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically, I am grouping with correlation id, once grouped i need timestamp of any event. (Screenshot below)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 15:23:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440751#M172448</guid>
      <dc:creator>sagar1992</dc:creator>
      <dc:date>2019-03-14T15:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract date of the latest event after group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440752#M172449</link>
      <description>&lt;P&gt;after your &lt;CODE&gt;|stats count ...&lt;/CODE&gt; you will lose your field DateTime.&lt;BR /&gt;
You can use &lt;CODE&gt;eventstats&lt;/CODE&gt; instead of &lt;CODE&gt;stats&lt;/CODE&gt; which will hold all your fields.&lt;/P&gt;

&lt;P&gt;To make things clear: does your search results all have the same value for &lt;CODE&gt;DateTime&lt;/CODE&gt;? Then you could add &lt;CODE&gt;DateTime&lt;/CODE&gt; to your by clause in your &lt;CODE&gt;stats&lt;/CODE&gt; command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test_mulesoft" sourcetype="SFTP-Highradius" 61c1bf00-45e7-11e9-bb4e-12376871b014 | rex field=_raw "corelationid.:\W+(?.)\"" | stats count as result values(numberOfRequests) as request_id by numberOfRequests DateTime | eval result = if (result==2,"SUCCESS","ERROR REPORTED") | table request_id,result,DateTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Mar 2019 15:36:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440752#M172449</guid>
      <dc:creator>damann</dc:creator>
      <dc:date>2019-03-14T15:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract date of the latest event after group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440753#M172450</link>
      <description>&lt;P&gt;Thanks for the reply @damann, however after using eventstats command, I am no longer able to get a single entry. however, able to retrieve date.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 16:51:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440753#M172450</guid>
      <dc:creator>sagar1992</dc:creator>
      <dc:date>2019-03-14T16:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract date of the latest event after group by?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440754#M172451</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/100559"&gt;@damann&lt;/a&gt; it worked.!! Thank You so much!!  I used dedup command to get rid of duplicate entry.&lt;/P&gt;

&lt;P&gt;Still in the learning phase. Thanks once again.&lt;/P&gt;

&lt;P&gt;index="test_mulesoft"  sourcetype="SFTP-Highradius" 61c1bf00-45e7-11e9-bb4e-12376871b014 | rex field=_raw "corelationid.&lt;EM&gt;:\W+(?.&lt;/EM&gt;)\"" | eventstats latest(numberOfRequests) as request_id by numberOfRequests | dedup request_id | table  _time,request_id&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:42:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-date-of-the-latest-event-after-group-by/m-p/440754#M172451</guid>
      <dc:creator>sagar1992</dc:creator>
      <dc:date>2020-09-29T23:42:18Z</dc:date>
    </item>
  </channel>
</rss>

