<?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 find missing values from a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477949#M134094</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;My database has two data sources. &lt;BR /&gt;
Data source 1 sends a string with a list of expected values, so the field might look like: exp_val="A B C"&lt;/P&gt;

&lt;P&gt;Data source 2 is sending up independent events each with a value. The database might contain re_val="A", re_val="B", re_val="D"&lt;/P&gt;

&lt;P&gt;I need Splunk to report that "C" is missing. We should be able to&lt;BR /&gt;
1 - Split the string into a table&lt;BR /&gt;
2 - Get all re_val from the database WHICH exist in the split_string_table (to eliminate "D")&lt;BR /&gt;
3 - diff [split_string_table] [result from 2]&lt;/P&gt;

&lt;P&gt;But for the life of me I cannot make it work. Below is my current attempt but I've tried about 100 variants to no avail....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval split_val_list = 
    [ search index="playground1" user="wkelsey" 
    | stats latest(exp_val) as exp_val by cell_name 
    | eval temp=split(exp_val, " ") 
    | mvexpand temp 
    | table temp] 
| set diff 
    [ search index="playground1" user="wkelsey" 
    | where in(re_val, split_val_list) 
    | table re_val] 
    [ table split_val_list]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;An alternative command which gives me the exact opposite of what I want&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="playground1" user="wkelsey"
| stats latest(exp_val) as exp_val 
| eval temp=split(exp_val, " ") 
| mvexpand temp 
| eval matchfield=temp 
| join matchfield 
    [ search index=playground1 user=wkelsey 
    | stats count by re_val 
    | table re_val 
    | eval matchfield= re_val] 
| table re_val
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As a new user to Splunk, I really question why they created a new language... The documentation is poor, SQL seems more powerful, and PHP or Python would give users more efficiency. I'm reading many posts of users spending days on simple searches.&lt;/P&gt;

&lt;P&gt;Splunk 6.6&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:34:23 GMT</pubDate>
    <dc:creator>wkelsey</dc:creator>
    <dc:date>2020-09-30T03:34:23Z</dc:date>
    <item>
      <title>How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477949#M134094</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;My database has two data sources. &lt;BR /&gt;
Data source 1 sends a string with a list of expected values, so the field might look like: exp_val="A B C"&lt;/P&gt;

&lt;P&gt;Data source 2 is sending up independent events each with a value. The database might contain re_val="A", re_val="B", re_val="D"&lt;/P&gt;

&lt;P&gt;I need Splunk to report that "C" is missing. We should be able to&lt;BR /&gt;
1 - Split the string into a table&lt;BR /&gt;
2 - Get all re_val from the database WHICH exist in the split_string_table (to eliminate "D")&lt;BR /&gt;
3 - diff [split_string_table] [result from 2]&lt;/P&gt;

&lt;P&gt;But for the life of me I cannot make it work. Below is my current attempt but I've tried about 100 variants to no avail....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval split_val_list = 
    [ search index="playground1" user="wkelsey" 
    | stats latest(exp_val) as exp_val by cell_name 
    | eval temp=split(exp_val, " ") 
    | mvexpand temp 
    | table temp] 
| set diff 
    [ search index="playground1" user="wkelsey" 
    | where in(re_val, split_val_list) 
    | table re_val] 
    [ table split_val_list]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;An alternative command which gives me the exact opposite of what I want&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="playground1" user="wkelsey"
| stats latest(exp_val) as exp_val 
| eval temp=split(exp_val, " ") 
| mvexpand temp 
| eval matchfield=temp 
| join matchfield 
    [ search index=playground1 user=wkelsey 
    | stats count by re_val 
    | table re_val 
    | eval matchfield= re_val] 
| table re_val
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As a new user to Splunk, I really question why they created a new language... The documentation is poor, SQL seems more powerful, and PHP or Python would give users more efficiency. I'm reading many posts of users spending days on simple searches.&lt;/P&gt;

&lt;P&gt;Splunk 6.6&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477949#M134094</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-09-30T03:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477950#M134095</link>
      <description>&lt;P&gt;Hopefully, I understood your question right&lt;/P&gt;

&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=playground1 user=wkelsey 
| stats count by re_val 
| append [ search index="playground1" user="wkelsey"
       | head 1 
       | eval re_val=split(exp_val, " ")
       | mvexpand re_val]
|stats count as total by re_val
| where total==1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Jan 2020 01:22:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477950#M134095</guid>
      <dc:creator>arjunpkishore5</dc:creator>
      <dc:date>2020-01-12T01:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477951#M134096</link>
      <description>&lt;P&gt;Revised:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval exp_val="A B C" 
| eval re_val = "" 
| appendpipe 
    [| eval exp_val="X Y Z" 
    | eval re_val="" 
    | appendpipe 
        [| eval exp_val="" 
        | eval re_val="A" 
        | appendpipe 
            [| eval exp_val="" 
            | eval re_val="B" 
            | appendpipe 
                [| eval exp_val="" 
                | eval re_val="D" 
                | appendpipe 
                    [| eval exp_val="" 
                    | eval re_val="Z"]]]]] 
| eventstats list(re_val) as re_val 
| eval exp_val=split(exp_val," ") 
| stats values(re_val) as re_val by exp_val 
| eval check = if(match(re_val,exp_val),"find","missing")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Recommended:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="playground1" user="wkelsey" 
| stats latest(exp_val) as exp_val values(re_val) as re_val
| eval exp_val = split(exp_val," ")
| stats values(re_val) as re_val by exp_val 
| where NOT match(re_val,exp_val)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result is missing value.&lt;/P&gt;

&lt;P&gt;The search was the opposite.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;STRONG&gt;Previous answer&lt;/STRONG&gt;&lt;BR /&gt;
Sample query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval exp_val="A B C" 
| eval re_val="A" 
| appendpipe 
    [| eval re_val="B"] 
| appendpipe 
    [| eval re_val="D" 
    | head 1] 
| rename COMMENT as "this is sample, please check it" 
| eval check = if(isnull(mvfind(split(exp_val," "),re_val)),"missing","find")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Recommended:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="playground1" user="wkelsey" 
| stats latest(exp_val) as exp_val list(re_val) as re_val 
| stats values(exp_val) as exp_val by re_val 
| where isnull(mvfind(split(exp_val," "),re_val))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result is missing value.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 09:26:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477951#M134096</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-12T09:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477952#M134097</link>
      <description>&lt;P&gt;In your sample query, the result is includes "D - missing", but I would like the results to include "C - missing" and not any "D - missing".&lt;BR /&gt;
There could be 1000 "re_val"s, we just want to find what is missing from exp_val&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477952#M134097</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-09-30T03:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477953#M134098</link>
      <description>&lt;P&gt;I didn't get the correct answers when I used this - but before debugging more, it looks like it will put "D" in the final results?&lt;BR /&gt;
The final result should just be "C"&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 17:51:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477953#M134098</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-01-13T17:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477954#M134099</link>
      <description>&lt;P&gt;Here is some example data, the results need to be "C", "X", "Y"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval exp_val="A B C" 
| eval re_val = "" 
| appendpipe 
    [| eval exp_val="X Y Z" 
    | eval re_val="" 
    | appendpipe 
        [| eval exp_val="" 
        | eval re_val="A" 
        | appendpipe 
            [| eval exp_val="" 
            | eval re_val="B" 
            | appendpipe 
                [| eval exp_val="" 
                | eval re_val="D" 
                | appendpipe 
                    [| eval exp_val="" 
                    | eval re_val="Z"]]]]]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 18:15:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477954#M134099</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-01-13T18:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477955#M134100</link>
      <description>&lt;P&gt;Is the search the exact opposite, I'm sorry.&lt;BR /&gt;
My answer is updated. please confirm,&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 19:31:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477955#M134100</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-13T19:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477956#M134101</link>
      <description>&lt;P&gt;Thanks for the help!&lt;BR /&gt;
This is closer, but not final.&lt;BR /&gt;
The results need to include "C", and nothing else. See the additional information I have given to my questions.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 20:01:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477956#M134101</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-01-13T20:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477957#M134102</link>
      <description>&lt;P&gt;Is my rivised answer(recommended) good?&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;additional information I have given to my questions.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;sorry, I can't find it.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 20:50:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477957#M134102</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-13T20:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477958#M134103</link>
      <description>&lt;P&gt;The revised answer is not what I need, sorry. &lt;BR /&gt;
Here is some example data, the only results given should be "C", "X" and "Y"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults 
 | eval exp_val="A B C" 
 | eval re_val = "" 
 | appendpipe 
     [| eval exp_val="X Y Z" 
     | eval re_val="" 
     | appendpipe 
         [| eval exp_val="" 
         | eval re_val="A" 
         | appendpipe 
             [| eval exp_val="" 
             | eval re_val="B" 
             | appendpipe 
                 [| eval exp_val="" 
                 | eval re_val="D" 
                 | appendpipe 
                     [| eval exp_val="" 
                     | eval re_val="Z"]]]]]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2020 21:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477958#M134103</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-01-13T21:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477959#M134104</link>
      <description>&lt;P&gt;sorry,I already provide the solution , the display is as you like .&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 22:00:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477959#M134104</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-13T22:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to find missing values from a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477960#M134105</link>
      <description>&lt;P&gt;Excellent, thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 22:04:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-missing-values-from-a-field/m-p/477960#M134105</guid>
      <dc:creator>wkelsey</dc:creator>
      <dc:date>2020-01-13T22:04:18Z</dc:date>
    </item>
  </channel>
</rss>

