<?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 generate a single search that uses inputlookup and join on multiple fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279383#M84391</link>
    <description>&lt;P&gt;Just repeat the &lt;CODE&gt;lookup&lt;/CODE&gt; for each field that needs to be match.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2016 23:13:53 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-10-24T23:13:53Z</dc:date>
    <item>
      <title>How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279378#M84386</link>
      <description>&lt;P&gt;I have a list of hosts that submit logs periodically.  I need Splunk to generate an alert if the last time it received a log from a host on this list is older than a configurable value per host.&lt;/P&gt;

&lt;P&gt;The list of hosts was created Excel, saved as a CSV, uploaded successfully into the Lookup Editor and is called criticalhosts.csv.  Below is the contents (I've used example data)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;IP        Hostname   FQDN                   MaxTimeoutInSeconds Function     Description
10.0.0.1    host1       host1.corpdomain.com    900                 webserver   Old Webserver
10.0.0.2    host2                               3600                   webserver    New Webserver
10.0.0.3                 host3.corpdomain.com   86400                 mailserver   Mailserver
10.0.0.4                                         300                    appserver   Appserver
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The data represents real hosts.  Within my domain, DNS is not necessarily well-maintained and does not always have entries for existing hosts.  As such, the "host" value in the logs is sometimes IP, sometimes hostname or sometimes FQDN.  While I agree this should be standardized, that's not the world I currently inhabit.&lt;/P&gt;

&lt;P&gt;The MaxTimeoutInSeconds value is the maximum amount of time in seconds allowable for the lastTime entry for a particular host.&lt;/P&gt;

&lt;P&gt;So, if I wanted to keep it simple and use a fixed time rather than the MaxTimeoutInSeconds of the lookup table, say at least 15 minutes old(900 seconds) but younger than 30 days old (2592000 seconds) I'd use the following. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts
| eval lastEventAgeInSeconds = (now() - lastTime)
| search lastEventAgeInSeconds &amp;gt; 900 lastEventAgeInSeconds &amp;lt; 2592000 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So far, so good.  Now, to use that data and find all log entries matching an IP in my lookup table and display them in a human format I'd use the following.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts
| eval lastEventAgeInSeconds = (now() - lastTime)
| search lastEventAgeInSeconds &amp;gt; 900 lastEventAgeInSeconds &amp;lt; 2592000 
| join [|inputlookup criticalhosts.csv | eval host=IP]
| convert ctime(lastTime) 
| table host Hostname FQND lastEventAgeInSeconds lastTime Function Description  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That gives me a very usable subset of what I want to know.  Now, I could create another search to find all log entries matching a hostname in my lookup table my changing the inputlookup statement like so.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| metadata type=hosts
| eval lastEventAgeInSeconds = (now() - lastTime)
| search lastEventAgeInSeconds &amp;gt; 900 lastEventAgeInSeconds &amp;lt; 2592000 
| join [|inputlookup criticalhosts.csv | eval host=Hostname]
| convert ctime(lastTime) 
| table host Hostname FQND lastEventAgeInSeconds lastTime Function Description  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that requires a separate search for matching IP, hostname or FQDN.  And that's not mentioning the use of the MaxTimeoutInSeconds value in the lookup table.&lt;/P&gt;

&lt;P&gt;==== HERE'S THE QUESTION ===&lt;BR /&gt;
How do I have a single search that matches against IP, hostname or FQDN in addition to using the MaxTimeoutInSeconds values in my lookup table instead of fixed timeouts?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 21:16:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279378#M84386</guid>
      <dc:creator>pcordel</dc:creator>
      <dc:date>2016-10-24T21:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279379#M84387</link>
      <description>&lt;P&gt;How about something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | metadata type=hosts
 | eval lastEventAgeInSeconds = (now() - lastTime)
 | lookup criticalhosts.csv Hostname as host 
 | where lastEventAgeInSeconds &amp;gt;  MaxTimeoutInSeconds
 | convert ctime(lastTime) 
 | table host Hostname FQND lastEventAgeInSeconds lastTime Function Description  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2016 22:00:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279379#M84387</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-24T22:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279380#M84388</link>
      <description>&lt;P&gt;Doesn't the lookup in your line 3&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| lookup criticalhosts.csv Hostname as host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;do the same thing as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| join [|inputlookup criticalhosts.csv | eval host=Hostname]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 22:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279380#M84388</guid>
      <dc:creator>pcordel</dc:creator>
      <dc:date>2016-10-24T22:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279381#M84389</link>
      <description>&lt;P&gt;&lt;CODE&gt;lookup&lt;/CODE&gt; command adds selected fields from the lookup file to matching events from your index, whereas &lt;CODE&gt;inputlookup append=t&lt;/CODE&gt; will append all data from the lookup. Here's more documentation on &lt;CODE&gt;lookup&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Lookup"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Lookup&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 22:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279381#M84389</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-24T22:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279382#M84390</link>
      <description>&lt;P&gt;I see that lookup works in the way you describe.  However, I don't see how it addresses my end question.  I see how your query matches my lookup table to my log entries if the log entry's "host" value is a Hostname.  If the log entry's "host" value is an IP or an FQDN, that host won't match the Hostname value in the lookup table.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 22:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279382#M84390</guid>
      <dc:creator>pcordel</dc:creator>
      <dc:date>2016-10-24T22:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279383#M84391</link>
      <description>&lt;P&gt;Just repeat the &lt;CODE&gt;lookup&lt;/CODE&gt; for each field that needs to be match.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 23:13:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279383#M84391</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-24T23:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279384#M84392</link>
      <description>&lt;P&gt;As it turns out, I had better success reversing the process a bit.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup criticalhosts.csv
| join type=inner IP[| metadata type=hosts | eval IP=host]
| join type=left Hostname[| metadata type=hosts | eval Hostname=host]
| join type=left Hostname[| metadata type=hosts | eval FQDN=host]
| eval lastEventAgeInSeconds = (now() - lastTime)
| where (lastEventAgeInSeconds &amp;gt; MaxTimeoutInSeconds) AND (lastEventAgeInSeconds &amp;lt; 2592000)
| convert ctime(lastTime) 
| table IP Hostname FQDN Function Description MaxTimeoutInSeconds lastEventAgeInSeconds lastTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Oct 2016 20:04:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279384#M84392</guid>
      <dc:creator>pcordel</dc:creator>
      <dc:date>2016-10-28T20:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a single search that uses inputlookup and join on multiple fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279385#M84393</link>
      <description>&lt;P&gt;Hi @pcordel - Is this a working solution that solved your question? If yes, please don't forget to resolve this post by clicking "Accept" below your answer. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2016 21:33:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-single-search-that-uses-inputlookup-and-join/m-p/279385#M84393</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2016-10-28T21:33:48Z</dc:date>
    </item>
  </channel>
</rss>

