<?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 search the time difference between a certain event and the event prior? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228698#M67665</link>
    <description>&lt;P&gt;It does!&lt;/P&gt;

&lt;P&gt;My next challenge is to get Splunk to differentiate the time stamps for each event at the location it happens, i.e, the time at each location where the earthquake happened.  I suppose that will be the subject of a subsearch.&lt;/P&gt;

&lt;P&gt;Anyways, thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2015 20:04:40 GMT</pubDate>
    <dc:creator>_dave_b</dc:creator>
    <dc:date>2015-11-17T20:04:40Z</dc:date>
    <item>
      <title>How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228690#M67657</link>
      <description>&lt;P&gt;I am trying to find the time of a type of event, and the time difference of the same type of event that happened just prior.  There are other events interspersed in the logs, but I am not interested in them.  So, for example, I want to find the times of all the earthquakes in California with magnitude larger than 2.  I can find the time of the latest and earliest earthquake without a problem, but it gets less clear if I want to get more specific than that, like getting the latest and the one before the latest.&lt;/P&gt;

&lt;P&gt;I just wish I could run a search, build an array from the results, then search through that array, but it seems as though I can't do that in Splunk. &lt;/P&gt;

&lt;P&gt;Does anyone have any ideas on how to accomplish this? &lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 19:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228690#M67657</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2015-11-16T19:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228691#M67658</link>
      <description>&lt;P&gt;If magnitude is a field, which I assume it is, just include in your search magnitude &amp;gt; 2.&lt;BR /&gt;
As for the event "just prior" - is there any extrapolation, in terms of time of event, that you can make?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 21:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228691#M67658</guid>
      <dc:creator>mreynov_splunk</dc:creator>
      <dc:date>2015-11-16T21:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228692#M67659</link>
      <description>&lt;P&gt;Hi, yes I include in my search magnitude &amp;gt; 2.  But I need the event times, which can be pretty random.&lt;/P&gt;

&lt;P&gt;The only extrapolation I can make for the "just prior" is that the previous earthquake happened prior to the most recent earthquake&lt;/P&gt;

&lt;P&gt;I thought I could do something like taking the last 2 events with head, then using tail on those events to triangulate the results to give me the second most recent event, but those commands don't seem to have that capability.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 21:32:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228692#M67659</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2015-11-16T21:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228693#M67660</link>
      <description>&lt;P&gt;Oh yeah, If I could somehow maintain a running "memory" of what the previous event's timestamp is across each event, that would make things better.  But I haven't seen a way to do that yet.  Streamstats maybe?  &lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 21:40:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228693#M67660</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2015-11-16T21:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228694#M67661</link>
      <description>&lt;P&gt;If this is something you need to do for an array of events, then yea, you should probably try streamstats.&lt;/P&gt;

&lt;P&gt;If just one, then you can try something like this: since you know the timestamp of the latest event, search for _timestamp &amp;lt; latest_event_timestamp and get the latest() out of the result set.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/149904/find-earliest-and-latest-event-per-day-for-a-time-range.html" target="_blank"&gt;https://answers.splunk.com/answers/149904/find-earliest-and-latest-event-per-day-for-a-time-range.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonstatsfunctions" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/SearchReference/Commonstatsfunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:55:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228694#M67661</guid>
      <dc:creator>mreynov_splunk</dc:creator>
      <dc:date>2020-09-29T07:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228695#M67662</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | reverse | streamstats current=f last(Magnitude) as prevMagnitude ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now that each event contains the magnitude of the previous event you no longer need any correlation between events so you can tack whatever you like onto the end:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | search magnitude &amp;gt; 3.3
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Nov 2015 22:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228695#M67662</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-16T22:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228696#M67663</link>
      <description>&lt;P&gt;I want to do something like what you said, but how do I pass the value for the latest event timestamp over?&lt;/P&gt;

&lt;P&gt;Would it be similar to this search?&lt;BR /&gt;
search magnitude &amp;gt; 3.3 | eval latest_event_timestamp = _time | search magnitude &amp;gt; 3.3 AND _timestamp &amp;lt; latest_event_stamp &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 07:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228696#M67663</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2020-09-29T07:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228697#M67664</link>
      <description>&lt;P&gt;My answer covers all this.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 18:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228697#M67664</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-17T18:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228698#M67665</link>
      <description>&lt;P&gt;It does!&lt;/P&gt;

&lt;P&gt;My next challenge is to get Splunk to differentiate the time stamps for each event at the location it happens, i.e, the time at each location where the earthquake happened.  I suppose that will be the subject of a subsearch.&lt;/P&gt;

&lt;P&gt;Anyways, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2015 20:04:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/228698#M67665</guid>
      <dc:creator>_dave_b</dc:creator>
      <dc:date>2015-11-17T20:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the time difference between a certain event and the event prior?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/660418#M227983</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;PRE&gt;... | reverse | streamstats current=f last(Magnitude) as prevMagnitude ...&lt;/PRE&gt;&lt;P&gt;Now that each event contains the magnitude of the previous event you no longer need any correlation between events so you can tack whatever you like onto the end:&lt;/P&gt;&lt;PRE&gt;... | search magnitude &amp;gt; 3.3&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Incredible answer!&amp;nbsp; So concise and powerful!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 16:40:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-time-difference-between-a-certain-event-and/m-p/660418#M227983</guid>
      <dc:creator>lmonahan</dc:creator>
      <dc:date>2023-10-11T16:40:51Z</dc:date>
    </item>
  </channel>
</rss>

