<?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 How to build a lookup table with a condition? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407739#M117751</link>
    <description>&lt;P&gt;I have a lookup of epoch times:&lt;/P&gt;

&lt;P&gt;epoch_time_lookup.csv&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Start Time  End Time
1529737700  1529737800
1529737600  1529737750
1529737800  1529737900
1529737720  1529737722
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have a search which gives me results with 2 columns. EPOCH TIME and AVAILABILITY&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EPOCH               AVAIL
1529737700  100
1529737600  100
1529737800  0
1529737720 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to build a search, whenever AVAIL == 0 , check if the EPOCH is between any START and END times in epoch_time_lookup.csv lookup.&lt;/P&gt;

&lt;P&gt;If yes, make availability 100.&lt;/P&gt;

&lt;P&gt;Eg:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= abc sourcetype=xyz | eval EPOCH = _time | eval AVAILABILITY = availability_field | **eval availability = (if EPOCH  in START and END of lookup) ,100, 0)**
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Need help in building the logic.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:11:25 GMT</pubDate>
    <dc:creator>joydeep741</dc:creator>
    <dc:date>2020-09-29T20:11:25Z</dc:date>
    <item>
      <title>How to build a lookup table with a condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407739#M117751</link>
      <description>&lt;P&gt;I have a lookup of epoch times:&lt;/P&gt;

&lt;P&gt;epoch_time_lookup.csv&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Start Time  End Time
1529737700  1529737800
1529737600  1529737750
1529737800  1529737900
1529737720  1529737722
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have a search which gives me results with 2 columns. EPOCH TIME and AVAILABILITY&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EPOCH               AVAIL
1529737700  100
1529737600  100
1529737800  0
1529737720 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to build a search, whenever AVAIL == 0 , check if the EPOCH is between any START and END times in epoch_time_lookup.csv lookup.&lt;/P&gt;

&lt;P&gt;If yes, make availability 100.&lt;/P&gt;

&lt;P&gt;Eg:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= abc sourcetype=xyz | eval EPOCH = _time | eval AVAILABILITY = availability_field | **eval availability = (if EPOCH  in START and END of lookup) ,100, 0)**
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Need help in building the logic.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:11:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407739#M117751</guid>
      <dc:creator>joydeep741</dc:creator>
      <dc:date>2020-09-29T20:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a lookup table with a condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407740#M117752</link>
      <description>&lt;P&gt;This solution is based on this other Q&amp;amp;A:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/648345/timechart-volume-per-hour-same-day-over-several-we.html"&gt;https://answers.splunk.com/answers/648345/timechart-volume-per-hour-same-day-over-several-we.html&lt;/A&gt;&lt;BR /&gt;
Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= abc sourcetype=xyz
| eval AVAILABILITY = availability_field
| eval availability = if([|inputlookup epoch_time_lookup.csv 
                          | rename "Start Time" AS time&amp;gt;, "End Time" AS time&amp;lt; 
                          | format 
                          | rex field=search mode=sed "s/time/_time/g s/\"//g"] ,100, 0)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Jun 2018 16:30:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407740#M117752</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-06-30T16:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to build a lookup table with a condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407741#M117753</link>
      <description>&lt;P&gt;@woodcock&lt;BR /&gt;
I corrected it.  Thanks a lot. &lt;BR /&gt;
What a genius way of doing this.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jul 2018 13:52:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-build-a-lookup-table-with-a-condition/m-p/407741#M117753</guid>
      <dc:creator>joydeep741</dc:creator>
      <dc:date>2018-07-01T13:52:39Z</dc:date>
    </item>
  </channel>
</rss>

