<?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: inputlookup search timerange in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150015#M185491</link>
    <description>&lt;P&gt;Edited my answer to show how to convert time to epoch&lt;/P&gt;</description>
    <pubDate>Thu, 21 Nov 2013 18:10:13 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2013-11-21T18:10:13Z</dc:date>
    <item>
      <title>inputlookup search timerange</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150011#M185487</link>
      <description>&lt;P&gt;Hello,I have created a csv similar to the one present on the musicdashboard tutorial&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;"_time", "origin", "destiny" ..&lt;BR /&gt;
"1384792901.868352", "example",&lt;BR /&gt;
"example" ..&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;and then I created the following searchmanager&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;{% searchmanager id="search-newsource"&lt;BR /&gt;
        search='| inputlookup newsource.csv | search&lt;BR /&gt;
origin=$originatorKey$ OR&lt;BR /&gt;
destiny=$recipientKey$&lt;BR /&gt;
        cache="False"&lt;BR /&gt;
earliest_time="$et$"|token_safe&lt;BR /&gt;
        latest_time="$lt$"|token_safe&lt;BR /&gt;
    %}&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;and the timerange is defined like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;{% timerange id="timeKey"&lt;BR /&gt;
earliest_time="$et$"|token_safe&lt;BR /&gt;
latest_time="$lt$"|token_safe %}&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Am I doing something wrong? This does not work.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:19:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150011#M185487</guid>
      <dc:creator>jpenetra</dc:creator>
      <dc:date>2020-09-28T15:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: inputlookup search timerange</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150012#M185488</link>
      <description>&lt;P&gt;Yes. The problem is that you are setting &lt;CODE&gt;earliest_time&lt;/CODE&gt; and &lt;CODE&gt;latest_time&lt;/CODE&gt; - but Splunk does not know how to relate that to the &lt;CODE&gt;_time&lt;/CODE&gt; field that you have defined in your lookup table. Also, it doesn't look like you closed the &lt;CODE&gt;search=&lt;/CODE&gt;; it appears to be missing a closing &lt;CODE&gt;'&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;When Splunk indexes &lt;EM&gt;events&lt;/EM&gt;, it creates an internal field called &lt;CODE&gt;_time&lt;/CODE&gt; for each event, and it knows how to relate that timestamp to the time range picker, as well as the search criteria for start and end times.&lt;/P&gt;

&lt;P&gt;None of that applies to lookup tables. In fact, you should not be creating field names in your lookup table that start with an underscore - user-created fields must start with an alphabetic character.&lt;/P&gt;

&lt;P&gt;You could, however, do the following and it should work:&lt;/P&gt;

&lt;P&gt;A. Change the field name in your .csv file --&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"timestamp", "origin", "destiny"
etc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;B. Change your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search="| inputlookup newsource.csv | search origin=$originatorKey$ OR destiny=$recipientKey$ cache=False timestamp &amp;gt;= $et$  timestamp &amp;lt;= $lt$" | token_safe
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, this assumes the data in &lt;CODE&gt;$et$&lt;/CODE&gt; and &lt;CODE&gt;$lt$&lt;/CODE&gt; is in the same numeric epoch time format as the csv file. But if it isn't, you will need to convert it before you do the comparison. Here's how:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search='| inputlookup newsource.csv | search origin=$originatorKey$ OR destiny=$recipientKey$ cache=False 
| eval et=$et$ | eval lt=$lt$ 
| eval startTime = case(et=="now",now(), et=="", now(), 1==1, relative_time(now(), et)
| eval endTime = case(lt=="now",now(), lt=="", now(), 1==1, relative_time(now(), lt)
| search timestamp &amp;gt;= startTime timestamp &amp;lt;= endTime' | token_safe
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2013 02:23:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150012#M185488</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-11-21T02:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: inputlookup search timerange</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150013#M185489</link>
      <description>&lt;P&gt;to further add onto this, you can use an eval with strptime to convert your timestamps into epoch time for comparisons and then strftime to convert them back into readable strings..&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2013 04:26:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150013#M185489</guid>
      <dc:creator>yong_ly</dc:creator>
      <dc:date>2013-11-21T04:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: inputlookup search timerange</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150014#M185490</link>
      <description>&lt;P&gt;Considering that I want the results of the Last 24 hours and $et$ matches to -24h@h and $lt$ to "now", how can I convert those to epoch time? Can't seem to find that answer.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2013 11:06:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150014#M185490</guid>
      <dc:creator>jpenetra</dc:creator>
      <dc:date>2013-11-21T11:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: inputlookup search timerange</title>
      <link>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150015#M185491</link>
      <description>&lt;P&gt;Edited my answer to show how to convert time to epoch&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2013 18:10:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/inputlookup-search-timerange/m-p/150015#M185491</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-11-21T18:10:13Z</dc:date>
    </item>
  </channel>
</rss>

