<?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: Whitelisting using lookups in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40805#M9428</link>
    <description>&lt;P&gt;Well, if I understand the question properly, your goal is to have a lookup table return a default value if the key does not exist in the lookup.  One way to accomplish this is by defining the lookup in &lt;CODE&gt;transforms.conf&lt;/CODE&gt; and setting a default match there.  A stanza similar to this should do it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[command_lookup]
filename=command_lookup.csv
min_matches = 1
default_match = NULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now your &lt;CODE&gt;lookup&lt;/CODE&gt; command in your search changes to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup command_lookup COMMAND AS COMMAND OUTPUT Classification AS Classification 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since the stanza defines the filename&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;One approach for post-processing exclusively in the search language is &lt;CODE&gt;eval&lt;/CODE&gt; and its &lt;CODE&gt;coalesce&lt;/CODE&gt; command.  You can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Classification=coalesce(Classification,'NULL')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;coalesce&lt;/CODE&gt; command returns the first non-empty value among its arguments.  &lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2013 17:13:21 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2013-02-22T17:13:21Z</dc:date>
    <item>
      <title>Whitelisting using lookups</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40804#M9427</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I don't know if this is the right way to do it, but I have a list of COMMANDS which I have associated a Classification (name).&lt;/P&gt;

&lt;P&gt;This search gives me a table with PID, COMMAND count and Classification and some of those results in the field Classification have blanks in it.&lt;PRE&gt;&lt;CODE&gt;sourcetype=top COMMAND | multikv | rex field=COMMAND "^(?&lt;COMMAND&gt;.+?)\/" | rex field=COMMAND "^(?&lt;COMMAND&gt;.+?)_" | dedup COMMAND | stats count by PID, COMMAND | lookup command_lookup.csv COMMAND AS COMMAND OUTPUT Classification AS Classification | eval Classification=if(isnull(Classification),command_lookup.csv,Classification)&lt;/COMMAND&gt;&lt;/COMMAND&gt;&lt;/CODE&gt;&lt;/PRE&gt;  What I am trying is to let Splunk write "NULL" in that field if it doesn't find a match in the lookup file.&lt;BR /&gt;
Or maybe the search query is just wrong.&lt;/P&gt;

&lt;P&gt;Can anybody help me here?&lt;/P&gt;

&lt;P&gt;thanks in advance.&lt;/P&gt;

&lt;P&gt;regards&lt;BR /&gt;
Mike&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:22:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40804#M9427</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2020-09-28T13:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Whitelisting using lookups</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40805#M9428</link>
      <description>&lt;P&gt;Well, if I understand the question properly, your goal is to have a lookup table return a default value if the key does not exist in the lookup.  One way to accomplish this is by defining the lookup in &lt;CODE&gt;transforms.conf&lt;/CODE&gt; and setting a default match there.  A stanza similar to this should do it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[command_lookup]
filename=command_lookup.csv
min_matches = 1
default_match = NULL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now your &lt;CODE&gt;lookup&lt;/CODE&gt; command in your search changes to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup command_lookup COMMAND AS COMMAND OUTPUT Classification AS Classification 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since the stanza defines the filename&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;One approach for post-processing exclusively in the search language is &lt;CODE&gt;eval&lt;/CODE&gt; and its &lt;CODE&gt;coalesce&lt;/CODE&gt; command.  You can do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Classification=coalesce(Classification,'NULL')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;coalesce&lt;/CODE&gt; command returns the first non-empty value among its arguments.  &lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2013 17:13:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40805#M9428</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2013-02-22T17:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Whitelisting using lookups</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40806#M9429</link>
      <description>&lt;P&gt;Hi dwaddle, thanks for your feedback.  Unfortunately I am not familiar with the stanza setup and in addition to that I have limited access (web interface only).&lt;/P&gt;

&lt;P&gt;I would appreciate a search command solution.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2013 19:14:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40806#M9429</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-02-22T19:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Whitelisting using lookups</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40807#M9430</link>
      <description>&lt;P&gt;Here is a tutorial on how to setup a lookup. It can be done entirely from the Splunk GUI.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Tutorial/Usefieldlookups"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Tutorial/Usefieldlookups&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Feb 2013 12:49:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whitelisting-using-lookups/m-p/40807#M9430</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-02-24T12:49:57Z</dc:date>
    </item>
  </channel>
</rss>

