<?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: Filtering lookups based on dates in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92940#M23967</link>
    <description>&lt;P&gt;Thanks for the pointer.  I have tried, but always get the first (earliest) record returned. In my example above, that would be WorkGroup1 for 2010-11-16 00:00:00, even though the event time is in April 2011.&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;P&gt;[UserLookup]&lt;/P&gt;

&lt;P&gt;default_match = Unknown&lt;/P&gt;

&lt;P&gt;filename = UserLookup.csv&lt;/P&gt;

&lt;P&gt;min_matches = 1&lt;/P&gt;

&lt;P&gt;time_field = ValidStart&lt;/P&gt;

&lt;P&gt;time_format = "%Y-%m-%d %H:%M:%S"&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2011 11:36:50 GMT</pubDate>
    <dc:creator>JovanMilosevic</dc:creator>
    <dc:date>2011-10-18T11:36:50Z</dc:date>
    <item>
      <title>Filtering lookups based on dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92938#M23965</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have some events, and a User lookup.   The Lookup holds the UserID, User Name,  a WorkGroup, and dates when the User was in that particular WorkGroup.  Users can move from one WorkGroup to another, and hence Users may have more than one record in the User lookup. &lt;/P&gt;

&lt;P&gt;What I'd like to produce is a report showing which WorkGroup the user was in at the time the event took place.&lt;/P&gt;

&lt;P&gt;My desired output would be along the lines of..&lt;/P&gt;

&lt;P&gt;user1 User One 2011-03-15 14:02:15 WorkGroup2&lt;/P&gt;

&lt;P&gt;because at the time of the event(2011-03-15 14:02:15), the User was in WorkGroup2.&lt;/P&gt;

&lt;P&gt;User Lookup&lt;/P&gt;

&lt;P&gt;UserID,Name,ValidStart,ValidEnd,WorkGroup&lt;/P&gt;

&lt;P&gt;user1,User One,2010-11-16 00:00:00,2011-01-20 00:00:00,WorkGroup1&lt;/P&gt;

&lt;P&gt;user1,User One,2011-01-21 00:00:00,2011-05-23 00:00:00,WorkGroup2&lt;/P&gt;

&lt;P&gt;user1,User One,2011-05-24 00:00:00,2011-10-31 00:00:00,WorkGroup1&lt;/P&gt;

&lt;P&gt;user2,User Two,2010-01-16 00:00:00,2011-08-23 00:00:00,WorkGroupX&lt;/P&gt;

&lt;P&gt;Here's my attempt, but I always get no records returned from the search. &lt;/P&gt;

&lt;P&gt;source="mysource" &lt;SOME more="" search="" terms=""&gt;&lt;/SOME&gt;&lt;/P&gt;

&lt;P&gt;| convert timeformat="%Y-%m-%d %H:%M:%S" ctime(_time) AS mytime&lt;/P&gt;

&lt;P&gt;| lookup UserLookup UserID AS UserID&lt;/P&gt;

&lt;P&gt;| where mytime&amp;gt;=ValidStart AND mytime&amp;lt;=ValidEnd&lt;/P&gt;

&lt;P&gt;| fields UserID, Name, mytime, WorkGroup&lt;/P&gt;

&lt;P&gt;I have verified that the event times do come within the range of Valid Start and End Dates.  If I replace the where with a search – no difference.&lt;/P&gt;

&lt;P&gt;If I remove the where altogether, and add in ValidStart and ValidEnd, I get all records as evpected.&lt;/P&gt;

&lt;P&gt;Any ideas ?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2011 16:57:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92938#M23965</guid>
      <dc:creator>JovanMilosevic</dc:creator>
      <dc:date>2011-10-17T16:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering lookups based on dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92939#M23966</link>
      <description>&lt;P&gt;you should look at temporal lookups that do mostly what you want. see the description on how to configure it in the transforms.conf.spec file: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Admin/Transformsconf&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;see the &lt;CODE&gt;time_field&lt;/CODE&gt;, &lt;CODE&gt;time_format&lt;/CODE&gt;, &lt;CODE&gt;max_offset_secs&lt;/CODE&gt;, and &lt;CODE&gt;min_offset_secs&lt;/CODE&gt; parameters.&lt;/P&gt;

&lt;P&gt;The limitation here is that you can only specify one single time, not a start and stop range. however, if we can assume only the start time, and assume that if there is an entry with a later start time, that one wins, then you can use that as the time field and leave the max and min offsets as default.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2011 20:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92939#M23966</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-10-17T20:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering lookups based on dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92940#M23967</link>
      <description>&lt;P&gt;Thanks for the pointer.  I have tried, but always get the first (earliest) record returned. In my example above, that would be WorkGroup1 for 2010-11-16 00:00:00, even though the event time is in April 2011.&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;P&gt;[UserLookup]&lt;/P&gt;

&lt;P&gt;default_match = Unknown&lt;/P&gt;

&lt;P&gt;filename = UserLookup.csv&lt;/P&gt;

&lt;P&gt;min_matches = 1&lt;/P&gt;

&lt;P&gt;time_field = ValidStart&lt;/P&gt;

&lt;P&gt;time_format = "%Y-%m-%d %H:%M:%S"&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2011 11:36:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92940#M23967</guid>
      <dc:creator>JovanMilosevic</dc:creator>
      <dc:date>2011-10-18T11:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering lookups based on dates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92941#M23968</link>
      <description>&lt;P&gt;Shouldn't have had the quotes around the time_format&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2011 18:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filtering-lookups-based-on-dates/m-p/92941#M23968</guid>
      <dc:creator>JovanMilosevic</dc:creator>
      <dc:date>2011-10-18T18:45:18Z</dc:date>
    </item>
  </channel>
</rss>

