<?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: Counting a value out of a lookup table that does not exist in the logs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352683#M104396</link>
    <description>&lt;P&gt;Try like this&lt;BR /&gt;
This is the updated query for your original requirement (avoiding join)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit action="login attempt" info=succeeded earliest=-7d@d [| inputlookup user_role_lookup.csv | rename userName AS user | table user]
| stats count by user
| append [| inputlookup user_role_lookup.csv | rename userName AS user | table user roles| eval count=0]
| stats values(roles) as roles max(count) as count by user
| where count=0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Add this to above query for your 2nd requirement&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;above query | table roles | dedup roles
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Sep 2017 00:12:56 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-09-21T00:12:56Z</dc:date>
    <item>
      <title>Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352681#M104394</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a search that works just fine that shows a list of users in a lookup table that have not logged into Splunk in the last 7 days:&lt;/P&gt;

&lt;P&gt;| inputlookup user_role_lookup.csv | rename userName AS user | table user | eval count=0 | join type=left user [search index=_audit action="login attempt" info=succeeded earliest=-7d@d | stats count by user] | where count=0&lt;/P&gt;

&lt;P&gt;The lookup table is simply 'userName' and 'roles' with about 190 entries. Roles, of course, is not a value in the _audit logs. I want to be able to show if no one from a particular role logged into Splunk in the last 7 days but replacing 'user' with 'roles' in the query above doesn't give me what I need. If it matters, the field 'roles' is the actual roles we created in Splunk pulled out using the REST command that was put into a lookup table.&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352681#M104394</guid>
      <dc:creator>ktaitingfong</dc:creator>
      <dc:date>2020-09-29T15:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352682#M104395</link>
      <description>&lt;P&gt;Try this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup user_role_lookup.csv 
| rename userName AS user 
| table user roles
| makemv roles
| mvexpand roles 
| eval mycount=0 
| join type=left user 
    [search index=_audit action="login attempt" info=succeeded earliest=-7d@d 
    | stats count as mycount by user] 
| stats sum(mycount) as mycount by role
| where mycount=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above code assumes that roles is a multivalue field that has been flattened to go into the csv and that may contain more than one role, separated by spaces.  If it is a single-value field, then the &lt;CODE&gt;makemv&lt;/CODE&gt; and &lt;CODE&gt;mvexpand&lt;/CODE&gt; are redundant but wont' break anything.  If there is some other way the field is constructed, such as pipe-delimited values, then you'll have to adjust hte code as needed.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 00:07:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352682#M104395</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-21T00:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352683#M104396</link>
      <description>&lt;P&gt;Try like this&lt;BR /&gt;
This is the updated query for your original requirement (avoiding join)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit action="login attempt" info=succeeded earliest=-7d@d [| inputlookup user_role_lookup.csv | rename userName AS user | table user]
| stats count by user
| append [| inputlookup user_role_lookup.csv | rename userName AS user | table user roles| eval count=0]
| stats values(roles) as roles max(count) as count by user
| where count=0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Add this to above query for your 2nd requirement&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;above query | table roles | dedup roles
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 00:12:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352683#M104396</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-09-21T00:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352684#M104397</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Oddly this produces no results with and without the makekv and kvexpand and even with the where mycount=0 has been removed.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 17:02:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352684#M104397</guid>
      <dc:creator>ktaitingfong</dc:creator>
      <dc:date>2017-09-21T17:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352685#M104398</link>
      <description>&lt;P&gt;Thanks for the help. Unfortunately, this gives me the same results I received previously which is showing me a zero count for roles and users although I have a user in the same role that did login. i.e.: Bob and Mary both have the role 'power' and Bob is showing up in the list, but since since Mary is in the same group and has logged in, 'power' shouldn't be in the results.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 17:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352685#M104398</guid>
      <dc:creator>ktaitingfong</dc:creator>
      <dc:date>2017-09-21T17:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352686#M104399</link>
      <description>&lt;P&gt;Hey @ktaitingfong, if they solved your problem, please don't forget to accept an answer! You can upvote posts as well. (Karma points will be awarded for either action.) Happy Splunking!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 23:11:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352686#M104399</guid>
      <dc:creator>lfedak_splunk</dc:creator>
      <dc:date>2017-09-21T23:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352687#M104400</link>
      <description>&lt;P&gt;@ktaitingfong - sorry about the delay,  Here's some debug steps.&lt;/P&gt;

&lt;P&gt;First, run this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit action="login attempt" info=succeeded earliest=-1h@h 
| stats count as mycount by user
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Verify that you have at least some records.  If not, then find the actual field name and rename it before the &lt;CODE&gt;stats&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;Next, run this and verify that multiple values in &lt;CODE&gt;roles&lt;/CODE&gt; are separated by spaces.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup user_role_lookup.csv 
| head 10 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next, try this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_audit action="login attempt" info=succeeded earliest=-1h@h 
| stats count as mycount by user

| rename COMMENT as "add roles from lookup, build key and copy roles to mycount records" 
| inputlookup append=t user_role_lookup.csv 
| eval user=coalesce(user, userName)
| eval mycount=coalesce(mycount,0)
| stats values(roles) as roles max(mycount) as mycount by user

| rename COMMENT as "split up the roles into separate records, then sum connections for each role" 
| eval roles=mvdedup(split(roles," ")) 
| mvexpand roles
| stats sum(mycount) as mycount by roles
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 20:16:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352687#M104400</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-06T20:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352688#M104401</link>
      <description>&lt;P&gt;Thanks, this gets me a lot closer. I think the problem I have now is that the roles field is multivalued but I can work that out. Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:57:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352688#M104401</guid>
      <dc:creator>ktaitingfong</dc:creator>
      <dc:date>2017-10-10T15:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Counting a value out of a lookup table that does not exist in the logs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352689#M104402</link>
      <description>&lt;P&gt;@ktaitingfong - are they separated by spaces, commas, or comma-space? &lt;/P&gt;

&lt;P&gt;Just modify this line to break it up into an official multivalue field, and it should work. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval roles=mvdedup(split(roles," ")) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Best wishes.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 16:39:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-a-value-out-of-a-lookup-table-that-does-not-exist-in/m-p/352689#M104402</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-10T16:39:03Z</dc:date>
    </item>
  </channel>
</rss>

