<?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 search events that contain a userID from a list? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400921#M116105</link>
    <description>&lt;P&gt;If you want to do the lookup approach then you’ll have to save the log/data file as csv and upload it.  See the documentation on adding lookups.&lt;/P&gt;

&lt;P&gt;Once you have it added as a lookup you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app_logs sourcetype=user_logs [|inputlookup lookupName.csv | fields userID | format]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Jun 2018 00:07:29 GMT</pubDate>
    <dc:creator>jkat54</dc:creator>
    <dc:date>2018-06-22T00:07:29Z</dc:date>
    <item>
      <title>How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400920#M116104</link>
      <description>&lt;P&gt;I have a list of userIDs on a text file, called WatchList.txt&lt;/P&gt;

&lt;P&gt;Splunk can natively parse out a field value pair (userID = John) from the logs I am searching.&lt;/P&gt;

&lt;P&gt;My list is as follows:&lt;/P&gt;

&lt;P&gt;userID&lt;BR /&gt;
John&lt;BR /&gt;
Mary&lt;BR /&gt;
Bob&lt;BR /&gt;
Paul&lt;/P&gt;

&lt;P&gt;I want write a query like this:&lt;/P&gt;

&lt;P&gt;index=app_logs  sourcetype=user_logs  | stats count by userID | WHERE (userID is on the list)&lt;/P&gt;

&lt;P&gt;I am not sure how to write it, or how I can use a lookup as an input to the search.&lt;/P&gt;

&lt;P&gt;index=app_logs  sourcetype=user_logs  [| inputlookup WatchList.txt] | stats count by userID&lt;/P&gt;

&lt;P&gt;Is this correct ???  Or is there a better way???&lt;/P&gt;

&lt;P&gt;Please provide an example.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400920#M116104</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2020-09-29T20:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400921#M116105</link>
      <description>&lt;P&gt;If you want to do the lookup approach then you’ll have to save the log/data file as csv and upload it.  See the documentation on adding lookups.&lt;/P&gt;

&lt;P&gt;Once you have it added as a lookup you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app_logs sourcetype=user_logs [|inputlookup lookupName.csv | fields userID | format]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jun 2018 00:07:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400921#M116105</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-22T00:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400922#M116106</link>
      <description>&lt;P&gt;That search would “unpack” to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app_logs sourcetype=user_logs ((userID=John) OR (userID=Mary) ...) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jun 2018 00:10:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400922#M116106</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-22T00:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400923#M116107</link>
      <description>&lt;P&gt;Thank you for the reply.&lt;BR /&gt;
I created a watchlist.txt and I ran &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app_logs sourcetype=user_logs [| inputlookup WatchList.txt] | stats count by userID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which gave me results, but are you saying it needs to be csv with a pipe to fields and pipe format, because docs indicate a .txt file is ok too?&lt;/P&gt;

&lt;P&gt;also is there a better way to write this?  in the subsearch I am not indicating an index or anything other than the list... is that correct?&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 12:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400923#M116107</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-06-22T12:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400924#M116108</link>
      <description>&lt;P&gt;The fields command is to be sure that you only select the field we want.  The format command is what makes each line in your lookup translate to ((field=value1fromlookup) OR (field=value2fromlookup))&lt;/P&gt;

&lt;P&gt;Though fields and format commands won’t always be required, they suit the needs for what you’ve asked.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 15:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400924#M116108</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-22T15:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400925#M116109</link>
      <description>&lt;P&gt;txt is ok if docs say so... &lt;/P&gt;

&lt;P&gt;Is your search right? I guess so... that is if you want to look through an index named app_logs where sourcetype=user_logs AND UserID=John AND UserID=Mary AND UserID=Bob AND UserID=Paul then transform the results into statistical count by UserID.&lt;/P&gt;

&lt;P&gt;But I though you wanted an OR condition between the UserID fields instead of the AND conditions.  Hence the need for the format command.  The fields command is just a best practice when helping others because if you have 3 columns in your lookup it would unpack to this instead:&lt;/P&gt;

&lt;P&gt;(&lt;BR /&gt;
headerfield1=row2col1 AND headerfield2=row2col2 AND headerfield3=row2col3&lt;BR /&gt;
)  OR/AND (&lt;BR /&gt;
headerfield1=row3col1 AND headerfield2=row3col2 AND headerfield3=row3col3&lt;BR /&gt;
)&lt;/P&gt;

&lt;P&gt;OR/AND if you dont/do use the format command.&lt;/P&gt;

&lt;P&gt;The fields reduces the count of the headerfield KvPs passed from the subsearch to the root search. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400925#M116109</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2020-09-29T20:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400926#M116110</link>
      <description>&lt;P&gt;Actually I might be off on how it unpacks without the format command but you can try and see for yourself.  Run each search and look at the job inspector.  In there look for the normalized search.  It should show you a better picture of what happens when you use format or fields, etc&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 15:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400926#M116110</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-06-22T15:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to search events that contain a userID from a list?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400927#M116111</link>
      <description>&lt;P&gt;I looked at a few of my old queries and read the docs again.  Your solution is correct if I want to use multiple field headers in my csv.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 13:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-events-that-contain-a-userID-from-a-list/m-p/400927#M116111</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-06-29T13:52:14Z</dc:date>
    </item>
  </channel>
</rss>

