<?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 query a lookup table based on time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488939#M136565</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="Tickets, Cases, Events, _time 
  10,      11,    45,     2019-11-01 
  14,      15,    79,     2019-11-02
  11,      22,    84,     2019-11-03"
| multikv forceheader=1
| rename time_ as _time
| foreach * 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = ltrim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;," ") ]
| eval _time=strptime(_time,"%Y-%m-%d")
| table Tickets, Cases, Events, _time
`comment("this is sample data, please use inputlookup")`
| where _time &amp;gt;= strptime("2019-11-01","%Y-%m-%d")
| table _time, Tickets, Cases, Events
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi,  @nirmalya2006&lt;BR /&gt;
Since your CSV's &lt;CODE&gt;_time&lt;/CODE&gt; is a &lt;STRONG&gt;string&lt;/STRONG&gt;, you cannot compare large and small at first.&lt;BR /&gt;
Therefore, you need to change the strings to hours ( &lt;CODE&gt;strptime&lt;/CODE&gt; )and compare them as hours.&lt;BR /&gt;
If the table order is changed in this way, a line chart can be displayed.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2019 23:49:26 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2019-11-22T23:49:26Z</dc:date>
    <item>
      <title>How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488934#M136560</link>
      <description>&lt;P&gt;HI All&lt;/P&gt;

&lt;P&gt;I have a lookup table which is populated by a scheduled search once everyday.&lt;BR /&gt;
The lookup table looks like below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Tickets, Cases, Events, _time 
 10,      11,    45,     2019-11-01 
 14,      15,    79,     2019-11-02
 11,      22,    84,     2019-11-03
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The query used to populate the lookup table is as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;index&amp;gt; &amp;lt;base search&amp;gt;
| timechart span=1d count by actionItem
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here the actionItems are Tickets, Cases, Events&lt;BR /&gt;
All this is fine, lookup is created, lookup is populating and fetching etc.&lt;/P&gt;

&lt;P&gt;But when I want to query the lookup table based on time, I am unable to do so.&lt;BR /&gt;
I tried using the below queries but none of them worked.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup lookup.csv 
| where strptime(_time, "%Y-%m-%d") &amp;gt;= "2019-11-01"
| table *

| inputlookup lookup.csv 
| search _time &amp;gt;= "2019-11-01"
| table *

| inputlookup cases_and_events.csv 
| search earliest="11/01/2019:00:00:00" latest="11/04/2019:00:00:00"
| table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can someone please point me to the right keywords to fetch the details based on _time.&lt;BR /&gt;
I understand that it seems the confusion is created because I have the column name as _time in thelookup csv&lt;BR /&gt;
This is because the initial look up load query was created using timechart.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 11:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488934#M136560</guid>
      <dc:creator>nirmalya2006</dc:creator>
      <dc:date>2019-11-22T11:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488935#M136561</link>
      <description>&lt;P&gt;Hi @nirmalya2006,&lt;BR /&gt;
did you explored the choice to use Summary index instead a time based lookup?&lt;BR /&gt;
In your scheduled searches you have to add the command &lt;CODE&gt;| collect index=my_summary_index&lt;/CODE&gt; instead &lt;CODE&gt;outputlookup&lt;/CODE&gt;.&lt;BR /&gt;
Then you can use the same approach of normal searches.&lt;/P&gt;

&lt;P&gt;Ciao.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 13:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488935#M136561</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-11-22T13:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488936#M136562</link>
      <description>&lt;P&gt;One cannot compare time strings, except [in]equality.  To find out if one time field is greater than another you must first convert them to integers.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup lookup.csv 
| eval time=strptime(_time, "%Y-%m-%d")
| search time &amp;gt;= relative_time(now(), "@m")
| table *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2019 14:07:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488936#M136562</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-11-22T14:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488937#M136563</link>
      <description>&lt;P&gt;Thanks @richgalloway, but this doesn't return any records. &lt;BR /&gt;
Basically I want to fetch the records between 11-01-2019 and 11-04-2019 irrespective of the current date.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 23:08:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488937#M136563</guid>
      <dc:creator>nirmalya2006</dc:creator>
      <dc:date>2019-11-22T23:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488938#M136564</link>
      <description>&lt;P&gt;Hi @gcusello, I did look at summary index, but my administrator has disabled it and the current need has too little data to be of good enough for summary index.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 23:10:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488938#M136564</guid>
      <dc:creator>nirmalya2006</dc:creator>
      <dc:date>2019-11-22T23:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488939#M136565</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="Tickets, Cases, Events, _time 
  10,      11,    45,     2019-11-01 
  14,      15,    79,     2019-11-02
  11,      22,    84,     2019-11-03"
| multikv forceheader=1
| rename time_ as _time
| foreach * 
    [ eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; = ltrim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;," ") ]
| eval _time=strptime(_time,"%Y-%m-%d")
| table Tickets, Cases, Events, _time
`comment("this is sample data, please use inputlookup")`
| where _time &amp;gt;= strptime("2019-11-01","%Y-%m-%d")
| table _time, Tickets, Cases, Events
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi,  @nirmalya2006&lt;BR /&gt;
Since your CSV's &lt;CODE&gt;_time&lt;/CODE&gt; is a &lt;STRONG&gt;string&lt;/STRONG&gt;, you cannot compare large and small at first.&lt;BR /&gt;
Therefore, you need to change the strings to hours ( &lt;CODE&gt;strptime&lt;/CODE&gt; )and compare them as hours.&lt;BR /&gt;
If the table order is changed in this way, a line chart can be displayed.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 23:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488939#M136565</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-22T23:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488940#M136566</link>
      <description>&lt;P&gt;This will use the &lt;CODE&gt;Time picker&lt;/CODE&gt; to control your time filter:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup cases_and_events.csv 
| eval _time = strptime(_time, "%Y-%m-%d")
| addinfo | rename info_* AS *
| where _time &amp;gt;= _info_min_time AND _time &amp;lt;= _info_max_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Nov 2019 06:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488940#M136566</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-23T06:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to query a lookup table based on time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488941#M136567</link>
      <description>&lt;P&gt;Bang on .. Thank you so much. &lt;BR /&gt;
I was thinking that _time in the csv was causing the problem.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 11:41:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-query-a-lookup-table-based-on-time/m-p/488941#M136567</guid>
      <dc:creator>nirmalya2006</dc:creator>
      <dc:date>2019-11-23T11:41:00Z</dc:date>
    </item>
  </channel>
</rss>

