<?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 perform a search in an index which filters out results with matching IPs and timestamps in the lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460117#M129807</link>
    <description>&lt;P&gt;First, _time is in epoch form, not a string.  It is converted to string format automatically when displayed.&lt;/P&gt;

&lt;P&gt;Second, how likely are you to get an event with a given IP address at the very second specified in the lookup file?  If the IP appears at different times it will not be filtered.&lt;/P&gt;

&lt;P&gt;If you still want to go down this path, try this query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = index  [|inputlookup lookuptable.csv | table src_a | eval _time=strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%3N%:z") | rename src_a as src | fields src, _time | format]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Mar 2020 17:38:41 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-03-26T17:38:41Z</dc:date>
    <item>
      <title>How to perform a search in an index which filters out results with matching IPs and timestamps in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460116#M129806</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a CSV file as lookup table which contains IP address and timestamp as fields. I need to perform a search in an index which filters out results with matching IPs and timestamps in the lookup table. &lt;/P&gt;

&lt;P&gt;I can filter out events with matching IPs with the following search string:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = index  [|inputlookup lookuptable.csv | table src_a | rename src_a as src]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The thing I just can't figure out is how could I match events with _time field and timestamp field in the lookup table. Timestamps in the file follow the same format as _time, for example, 2020-02-24T12:10:10.000+02:00&lt;/P&gt;

&lt;P&gt;What should I add to the search string to match timestamps as well?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:05:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460116#M129806</guid>
      <dc:creator>canyin</dc:creator>
      <dc:date>2020-03-26T17:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a search in an index which filters out results with matching IPs and timestamps in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460117#M129807</link>
      <description>&lt;P&gt;First, _time is in epoch form, not a string.  It is converted to string format automatically when displayed.&lt;/P&gt;

&lt;P&gt;Second, how likely are you to get an event with a given IP address at the very second specified in the lookup file?  If the IP appears at different times it will not be filtered.&lt;/P&gt;

&lt;P&gt;If you still want to go down this path, try this query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = index  [|inputlookup lookuptable.csv | table src_a | eval _time=strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%3N%:z") | rename src_a as src | fields src, _time | format]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:38:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460117#M129807</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-03-26T17:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a search in an index which filters out results with matching IPs and timestamps in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460118#M129808</link>
      <description>&lt;P&gt;You cannot format _time field. Instead of using _time to filter use actual timestamp field in the index whose values are same as _time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = index  [|inputlookup lookuptable.csv | table src_a, timestamp | rename src_a as src, timestamp as timestamp_field_in_index | format]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460118#M129808</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-26T17:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a search in an index which filters out results with matching IPs and timestamps in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460119#M129809</link>
      <description>&lt;P&gt;Good point about &lt;CODE&gt;format&lt;/CODE&gt; and _time.  Your solution should work if the OP's events have two timestamp fields (_time and another).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460119#M129809</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-09-30T04:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a search in an index which filters out results with matching IPs and timestamps in the lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460120#M129810</link>
      <description>&lt;P&gt;Your &lt;CODE&gt;lookup file&lt;/CODE&gt; probably has an incorrect format for time.  You did not tell us the names of your fields so I am going to assume that you have a field called &lt;CODE&gt;_time&lt;/CODE&gt; in your &lt;CODE&gt;lookup file&lt;/CODE&gt;.  Start with this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup lookuptable.csv | rename _time AS time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the values for &lt;CODE&gt;time&lt;/CODE&gt; are numbers, you are good-to-go.  If not, you need to convert it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup lookuptable.csv
| rename YourTimeFIeldNameHere AS _time
| eval _time = strptime(_time, "%Y-%m-%dT%H:%M:%S.%3n%z")
| outputlookup lookuptable.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OK, now you have a valid name for your time field and valid values, too.&lt;BR /&gt;
Now you can create a &lt;CODE&gt;lookup definition&lt;/CODE&gt; that will allow you to do a &lt;CODE&gt;time-based lookup&lt;/CODE&gt; OR filter like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = index AND [|inputlookup lookuptable.csv | table _time src_a
| rename _time AS time
| format
| rex field=search mode=sed "s/time/_time/g" ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Apr 2020 13:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-a-search-in-an-index-which-filters-out-results/m-p/460120#M129810</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-04-03T13:13:45Z</dc:date>
    </item>
  </channel>
</rss>

