<?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 find list of all events within time window of other events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-list-of-all-events-within-time-window-of-other/m-p/443060#M125731</link>
    <description>&lt;P&gt;Try something like this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=A ( ErrorCode=2 OR ErrorCode=3) 
 [ search index=B  Criteria=1
 | table _time userName
 | eval earliest=_time 
 | eval latest=_time+60 
 | fields - _time
 | format "(" "(" "" ")" "OR" ")" 
 | rex mode=sed field=search "s/\"//g" 
 ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The return values from the search code in square brackets end up being formatted something like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;( ( earliest=1536192351.692 latest=1536192411.692  userName=value1  ) OR 
  ( earliest=1536192351.692 latest=1536192411.692  userName=value2  ) OR ... )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where those 153619235X.XXX values are epoch times.  &lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;rex&lt;/CODE&gt; line kills the quotes around the values, which must be done for the earliest and latest values to be interpreted correctly.&lt;/P&gt;

&lt;P&gt;If &lt;CODE&gt;userNames&lt;/CODE&gt; may contain internal quotes or special characters, then the &lt;CODE&gt;rex&lt;/CODE&gt; should be replaced by a &lt;CODE&gt;strftime&lt;/CODE&gt; command back when the values of &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; are being calculated, to translate them into the character values accepted by Splunk.  &lt;/P&gt;

&lt;P&gt;Let us know if you need that.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Sep 2018 23:54:41 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2018-09-05T23:54:41Z</dc:date>
    <item>
      <title>How to find list of all events within time window of other events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-list-of-all-events-within-time-window-of-other/m-p/443059#M125730</link>
      <description>&lt;P&gt;I have a query that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=A ( ErrorCode=2 OR ErrorCode=3) 
    [ search index=B  Criteria=1
    | table userName]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This query will look for all users that have criteria=1 in their event, and then look to see if they have criteria 2 (in a separate index/sourcetype).&lt;/P&gt;

&lt;P&gt;However, what I am really looking for is the events that occur 1 minute after Criteria 1 is triggered. I want to see how many users are experiencing errors right after criteria 1 is triggered. With this search, if a user experienced the criteria yesterday, but the errors today, it would show up.&lt;/P&gt;

&lt;P&gt;I assume I need to carry the &lt;CODE&gt;_time&lt;/CODE&gt; field over somehow and marry it to the username? Not sure how to go about doing this.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 00:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-list-of-all-events-within-time-window-of-other/m-p/443059#M125730</guid>
      <dc:creator>brajaram</dc:creator>
      <dc:date>2018-09-05T00:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to find list of all events within time window of other events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-list-of-all-events-within-time-window-of-other/m-p/443060#M125731</link>
      <description>&lt;P&gt;Try something like this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=A ( ErrorCode=2 OR ErrorCode=3) 
 [ search index=B  Criteria=1
 | table _time userName
 | eval earliest=_time 
 | eval latest=_time+60 
 | fields - _time
 | format "(" "(" "" ")" "OR" ")" 
 | rex mode=sed field=search "s/\"//g" 
 ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The return values from the search code in square brackets end up being formatted something like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;( ( earliest=1536192351.692 latest=1536192411.692  userName=value1  ) OR 
  ( earliest=1536192351.692 latest=1536192411.692  userName=value2  ) OR ... )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where those 153619235X.XXX values are epoch times.  &lt;/P&gt;

&lt;P&gt;The &lt;CODE&gt;rex&lt;/CODE&gt; line kills the quotes around the values, which must be done for the earliest and latest values to be interpreted correctly.&lt;/P&gt;

&lt;P&gt;If &lt;CODE&gt;userNames&lt;/CODE&gt; may contain internal quotes or special characters, then the &lt;CODE&gt;rex&lt;/CODE&gt; should be replaced by a &lt;CODE&gt;strftime&lt;/CODE&gt; command back when the values of &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; are being calculated, to translate them into the character values accepted by Splunk.  &lt;/P&gt;

&lt;P&gt;Let us know if you need that.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 23:54:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-list-of-all-events-within-time-window-of-other/m-p/443060#M125731</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-09-05T23:54:41Z</dc:date>
    </item>
  </channel>
</rss>

