<?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 pull data from a lookup within a date range? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459820#M5894</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=table1
| lookup account_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS servacct Time AS ark_time 
| where strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;gt; strptime(table1_time, "%m/%d/%Y %H:%M:%S") and strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;lt;= relative_time(strptime(table1_time, "%m/%d/%Y %H:%M:%S"),"+72h")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Jul 2018 17:45:43 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-07-25T17:45:43Z</dc:date>
    <item>
      <title>How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459818#M5892</link>
      <description>&lt;P&gt;I created a lookup definition, account_admin, for a csv file that I have. &lt;BR /&gt;
ark_admin - file - Time,User,Source IP,Service Account,Action,Service Account Path,Server Connection, Message&lt;/P&gt;

&lt;P&gt;Here is a sample of the lookup data: &lt;BR /&gt;
Action, Message, Server Connection, Service Path, Service Acct, Source IP, Time, User&lt;BR /&gt;
Retrieve password,126.259.193.138,(Action: Connect)(Connection to address: server1234),ServerAdmins.com-PROD_5,PROD_5,126.259.125.36,07/10/2018 15:45:41,&lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Here is a sample of the table1 data:&lt;BR /&gt;
table1_time, email, host, _time&lt;BR /&gt;
07/24/2018 09:26:01, &lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server1234, 2018-07-24 10:30:00.987&lt;BR /&gt;
07/23/2018 06:16:01, &lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server3234, 2018-07-23 11:30:00.987&lt;BR /&gt;
07/22/2018 08:16:01, &lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server2234, 2018-07-22 09:30:00.987&lt;/P&gt;

&lt;P&gt;When I run my lookup now, it pulls all the servers for the specific email address I'm searching for (User as email) and adds it to the same record. I would like to limit the list to a specific date range. When I run the following, I get no results.&lt;/P&gt;

&lt;P&gt;sourcetype=table1&lt;BR /&gt;
| eval endepochDate=relative_time(strptime(table1_time, "%m/%d/%Y %H:%M:%S"), "+72H@H")&lt;BR /&gt;
| eval endate = strftime(endepochDate, "%m/%d/%Y %H:%M:%S")&lt;BR /&gt;
| lookup account_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS servacct Time AS ark_time &lt;BR /&gt;
| where ark_time &amp;gt; table1_time and ark_time &amp;lt;= endate&lt;/P&gt;

&lt;P&gt;All the dates are the same format, "%m/%d/%Y %H:%M:%S", so I'm not sure why it isn't working. If I need to compare by converting to Unix time, how would I do that with the lookup?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:38:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459818#M5892</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2020-09-29T20:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459819#M5893</link>
      <description>&lt;P&gt;Have you tried using &lt;CODE&gt;OUTPUT&lt;/CODE&gt; instead of &lt;CODE&gt;OUTPUTNEW&lt;/CODE&gt;? Do you have an existing field you want your lookup to overwrite? &lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 17:06:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459819#M5893</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2018-07-25T17:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459820#M5894</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=table1
| lookup account_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS servacct Time AS ark_time 
| where strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;gt; strptime(table1_time, "%m/%d/%Y %H:%M:%S") and strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;lt;= relative_time(strptime(table1_time, "%m/%d/%Y %H:%M:%S"),"+72h")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 17:45:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459820#M5894</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-25T17:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459821#M5895</link>
      <description>&lt;P&gt;I think you do some unnecessary conversion on time fields. you could simply connect all in epoch with strptime() and make your comparisons&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval endepochDate=relative_time(strptime(table1_time, "%m/%d/%Y %H:%M:%S"), "+72H@H") 
| lookup account_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS servacct Time AS ark_time 
| where strptime(ark_time,"%m/%d/%Y %H:%M:%S") &amp;gt; strptime(table1_time,"%m/%d/%Y %H:%M:%S") and strptime(ark_time,"%m/%d/%Y %H:%M:%S") &amp;lt;= endepochDate
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 17:45:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459821#M5895</guid>
      <dc:creator>akocak</dc:creator>
      <dc:date>2018-07-25T17:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459822#M5896</link>
      <description>&lt;P&gt;Not getting any results with those. I have tested, and verified that the strptime() functions that were suggested are working. I think the problem is that when I do the lookup, I am getting multiple matches for each lookup. &lt;/P&gt;

&lt;P&gt;For example the result I get without the where statement produces the following results:&lt;/P&gt;

&lt;P&gt;User, Server, ark_time, table1_time&lt;BR /&gt;
&lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server1234 server2234 server3234 server4234 server5234, 07/11/2018 14:29:00   07/24/2018 09:44:49 07/24/2018 11:13:51 07/10/2018 15:45:41 07/10/2018 15:45:41, 07/24/2018 09:26:00&lt;/P&gt;

&lt;P&gt;It looks like when it does the lookup, it grabs all matching data for the user account (User) and puts it all into one record. So I get multiple servers and multiple dates related to those servers, but they are placed in different fields. It doesn't seem like it works like when you compare table to table, where there would be multiple records for the same search. It looks like it is putting all the data it finds into fields for the single record.  &lt;/P&gt;

&lt;P&gt;Is there a way to do the lookup differently? Or is there another function I need to use to break out the multiple entries in the fields into records that I can then search for the date range?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459822#M5896</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2020-09-29T20:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459823#M5897</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=table1
 | lookup account_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS servacct Time AS ark_time | mvexpand ark_time
 | where strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;gt; strptime(table1_time, "%m/%d/%Y %H:%M:%S") and strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;lt;= relative_time(strptime(table1_time, "%m/%d/%Y %H:%M:%S"),"+72h")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 19:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459823#M5897</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-25T19:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459824#M5898</link>
      <description>&lt;P&gt;That's closer! So now it is selecting the records within the times, but I have multiple servers in those records. &lt;BR /&gt;
I'm going down this path, not sure if this is the right way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup account_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS servacct Time AS ark_time 
| mvexpand ark_time
| where strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;gt; strptime(table1_time, "%m/%d/%Y %H:%M:%S") and strptime(ark_time, "%m/%d/%Y %H:%M:%S") &amp;lt;= relative_time(strptime(table1_time, "%m/%d/%Y %H:%M:%S"),"+72h")
| rex field=servcon "address: (?&amp;lt;Server&amp;gt;[^)]+)"
| eval fields1= mvzip(mvzip (Server, servacct),ark_time)
| mvexpand fields1
| rex field=fields1 "(?&amp;lt;serveraccessed&amp;gt;\w+),(?&amp;lt;serviceacct&amp;gt;\w+),(?&amp;lt;timeaccessed&amp;gt;\d+\D\d+\D\d+\D\S\d+\D\d+\D\d+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;fields1 =   server1234,PROD_7,07/25/2018 15:45:35&lt;BR /&gt;
But it doesn't look like the last rex is working. &lt;/P&gt;

&lt;P&gt;Update: got the rex to work with the above syntax. Still learning the whole regex/rex stuff. &lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 20:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459824#M5898</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2018-07-25T20:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull data from a lookup within a date range?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459825#M5899</link>
      <description>&lt;P&gt;With your additional suggestion of MVEXPAND, I learned about those functions and was able to finally make it work as I wanted. Thanks so much for the help!! &lt;/P&gt;

&lt;P&gt;This query splits the multi-value fields of 'Server', 'serviceAcct', and 'ark_time' into separate fields that can then be compared/sorted. &lt;BR /&gt;
'Server' is pulled from a field (servcon) that looks like this: "   (Action: Connect)(Connection to address: servername1234)"&lt;BR /&gt;
The multi-value fields are combined into combinedFields&lt;BR /&gt;
combinedFields is then mvexpanded to created additional records&lt;/P&gt;

&lt;P&gt;The data goes from this:&lt;BR /&gt;
User, Server, serviceAcct, ark_time, Orig_time&lt;BR /&gt;
&lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server1234 server2234 server3234 server4234 server5234, PROD_4, PROD_4, PROD_5, PROD_4, PROD_3, 07/11/2018 14:29:00 07/24/2018 09:44:49 07/24/2018 11:13:51 07/10/2018 15:45:41 07/10/2018 15:45:41, 07/24/2018 09:26:00&lt;/P&gt;

&lt;P&gt;To this: &lt;BR /&gt;
User, Server, serviceAcct, ark_time, Orig_time&lt;BR /&gt;
&lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server1234, PROD_4, 07/11/2018 14:29:00, 07/24/2018 09:26:00&lt;BR /&gt;
&lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server2234, PROD_4, 07/24/2018 09:44:49 , 07/24/2018 09:26:00&lt;BR /&gt;
&lt;A href="mailto:Some.Guy@nowhere.com" target="_blank"&gt;Some.Guy@nowhere.com&lt;/A&gt;, server3234, PROD_5, 07/24/2018 11:13:51 , 07/24/2018 09:26:00&lt;BR /&gt;
etc&lt;/P&gt;

&lt;P&gt;Here is the completed query for future reference:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rename OVW_Value1 as serverRequested, OVW_Value2 as userName, OVW_Value3 as requestDate, OVW_Value4 as requestHour, OVW_Value5 as Orig_time, USR_EMAIL1 as email
| lookup ark_admin User as email OUTPUTNEW "Server Connection" AS servcon "Service Account" AS serviceAcct Time AS ark_time
| rex field=servcon "address: (?&amp;lt;Server&amp;gt;[^)]+)"
| eval EndTime = strftime(relative_time(strptime(Orig_time, "%m/%d/%Y %H:%M:%S"),"+72h"),"%m/%d/%Y %H:%M:%S")
| eval combinedFields= mvzip (mvzip (Server,serviceAcct),ark_time)
| mvexpand combinedFields
| rex field=fields1 "(?&amp;lt;serverAccessed&amp;gt;\w+),(?&amp;lt;serviceAcctUsed&amp;gt;\w+),(?&amp;lt;serverTimeAccessed&amp;gt;\d+\D\d+\D\d+\D\S\d+\D\d+\D\d+)"
| where strptime(serverTimeAccessed, "%m/%d/%Y %H:%M:%S") &amp;gt; strptime(Orig_time, "%m/%d/%Y %H:%M:%S") and strptime(serverTimeAccessed, "%m/%d/%Y %H:%M:%S") &amp;lt;= relative_time(strptime(Orig_time, "%m/%d/%Y %H:%M:%S"),"+72h")
| table email userName serverRequested serverTimeAccessed serviceAcctUsed serverAccessed Orig_time EndTime
| sort +serverTimeAccessed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-pull-data-from-a-lookup-within-a-date-range/m-p/459825#M5899</guid>
      <dc:creator>batsonpm</dc:creator>
      <dc:date>2020-09-29T20:39:43Z</dc:date>
    </item>
  </channel>
</rss>

