<?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: Subsearch based on date in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16396#M2190</link>
    <description>&lt;P&gt;Hi, I see a couple other choices depending on the "full" use-case. In both cases, you will first need to conver ModifiedTime to epoch (as nick said):&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;...| eval ModifiedTime=mktime(ModifiedTime)&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;then:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;use the "map" command&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;.... | map search="search sourcetype::eventtwo starttimeu::$ModifiedTime$ endtimeu::$ModifiedTime$"&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;You could also use other fields from event one to refine the search for event two.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;use the "join" command&lt;/P&gt;

&lt;P&gt;"remap" modifiedTime to _time on event one (and backup the original _time, if needed):&lt;/P&gt;

&lt;P&gt;*... | eval orig_time=_time | eval _time=ModifiedTime*&lt;/P&gt;

&lt;P&gt;then join on _time&lt;/P&gt;

&lt;P&gt;*... | join _time [search sourcetype::eventtwo ...]*&lt;/P&gt;

&lt;P&gt;This will add the fields from eventtwo to the results of eventone.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Good luck!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jun 2010 23:29:05 GMT</pubDate>
    <dc:creator>Paolo_Prigione</dc:creator>
    <dc:date>2010-06-30T23:29:05Z</dc:date>
    <item>
      <title>Subsearch based on date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16392#M2186</link>
      <description>&lt;P&gt;I'm new to creating subsearches. I need to combine fields from two different sourcetypes based on a date. Event one have a field "Modified time", event 2 is just using _time. I need to find event one and do a query for event 2 where _time="Modified time".&lt;/P&gt;

&lt;P&gt;Can anyone give me a quick tip on how to do this?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2010 04:44:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16392#M2186</guid>
      <dc:creator>snowmizer</dc:creator>
      <dc:date>2010-06-29T04:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch based on date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16393#M2187</link>
      <description>&lt;P&gt;Any chance you can give us some examples of the events you are searching over?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2010 06:39:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16393#M2187</guid>
      <dc:creator>bfaber</dc:creator>
      <dc:date>2010-06-29T06:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch based on date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16394#M2188</link>
      <description>&lt;P&gt;Also clarify if event 2 is the event coming from your subsearch?  What do you want to do with your events that you've matched up?  It's also possible that you don't need to use subsearch for this at all.  But more specific information is needed.  (Please be sure to use the "edit" link to add additional details to your existing question.)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2010 00:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16394#M2188</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-06-30T00:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch based on date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16395#M2189</link>
      <description>&lt;P&gt;this may help point you in the right direction.&lt;BR /&gt;
If you want to manually control what comes out of the subsearch you have to restrict to 1 row, restrict to 1 field in that row,  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search for event 2&amp;gt; earliest=[search &amp;lt;search for event 1&amp;gt; | head 1 | eval search=yourModifiedTimeField | fields search] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will search for event 1, and get the yourModifiedTimeField value, and then run the search for event 2 with earliest=123132841 or whatever the value of yourModifiedTimeField is. &lt;/P&gt;

&lt;P&gt;NOTE: this example will only work as written if your 'modifiedTime' field is an epochTime value, ie number of seconds since 1/1/1970.&lt;BR /&gt;
If its not then either: &lt;/P&gt;

&lt;P&gt;a) you'll have to use the convert command, or the eval command with the new fancy time operators like ctime,strftime etc, to turn it into an epochTime value.   (its not that bad once you get used to it)&lt;/P&gt;

&lt;P&gt;b) Or if the field value is a string time and you dont feel like learning how to use convert/eval/etc you can specify a timeformat="%M/%D/%Y:%H:%M:%S" string, but it has to be an exact match, and the timeformat term (somewhat bizarrely) has to be before the earliest= or it wont work. &lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2010 10:38:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16395#M2189</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-06-30T10:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch based on date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16396#M2190</link>
      <description>&lt;P&gt;Hi, I see a couple other choices depending on the "full" use-case. In both cases, you will first need to conver ModifiedTime to epoch (as nick said):&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;...| eval ModifiedTime=mktime(ModifiedTime)&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;then:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;use the "map" command&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;.... | map search="search sourcetype::eventtwo starttimeu::$ModifiedTime$ endtimeu::$ModifiedTime$"&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;You could also use other fields from event one to refine the search for event two.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;use the "join" command&lt;/P&gt;

&lt;P&gt;"remap" modifiedTime to _time on event one (and backup the original _time, if needed):&lt;/P&gt;

&lt;P&gt;*... | eval orig_time=_time | eval _time=ModifiedTime*&lt;/P&gt;

&lt;P&gt;then join on _time&lt;/P&gt;

&lt;P&gt;*... | join _time [search sourcetype::eventtwo ...]*&lt;/P&gt;

&lt;P&gt;This will add the fields from eventtwo to the results of eventone.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2010 23:29:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16396#M2190</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2010-06-30T23:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch based on date</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16397#M2191</link>
      <description>&lt;P&gt;I would recommend against the syntax &lt;CODE&gt;earliest=[ ... | eval search=XXXX | fields search ]&lt;/CODE&gt; in favor of &lt;CODE&gt;[ ... | eval earliest=XXXX | fields earliest]&lt;/CODE&gt; because the latter will work as expected even if you have more than one result from the subsearch.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2010 21:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-based-on-date/m-p/16397#M2191</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-11-18T21:34:24Z</dc:date>
    </item>
  </channel>
</rss>

