<?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 find results present in index and not in lookup table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624769#M217189</link>
    <description>&lt;P&gt;You can approach it from a different side completely.&lt;/P&gt;&lt;P&gt;Instead of building a condition for your search, you can just search across all data (it's tstats so it should be reasonably quick) and filter out the "bad" entries&lt;/P&gt;&lt;PRE&gt;| tstats count where index IN ("your","set","of","indexes","or","*") host IN ("another","set","or","*") by host index&lt;BR /&gt;| lookup yourlookup index host OUTPUT index as found_index&lt;BR /&gt;| where NOT index=found_index&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But you can still build your search by excluding from tstats directly&lt;/P&gt;&lt;PRE&gt;| tstats count where&lt;BR /&gt;   [ | inputlookup yourlookup&lt;BR /&gt;     | table index ] NOT&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [ | inputlookup yourlookup&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | table host index ]&lt;BR /&gt;BY host index&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Dec 2022 22:13:34 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-12-19T22:13:34Z</dc:date>
    <item>
      <title>How to find results present in index and not in lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624758#M217181</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have enquired this problem earlier in older threads, however, could not get a working answer, thus, created a new thread to get wider visibility and response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Resources in hand: -&lt;/P&gt;&lt;P&gt;I have a lookup table which has many fields. I have two fields to consider: - index, host&lt;BR /&gt;I have a list of indexes for which results need to be fetched.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Requirement: -&lt;/P&gt;&lt;P&gt;I need to fetch list of those hosts for each index value whose records are fetched in index but not fetched from lookup table. For fetching the events from index, I need to get the list of index values from lookup table.&lt;/P&gt;&lt;P&gt;I tried the below however, I am getting hosts which are fetched in both index and lookup table: -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|tstats fillnull_value="unknown" count AS event_count
WHERE
[
|inputlookup table1
|stats count BY index
|foreach index
[eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=replace(replace(lower(trim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)),"\s+",""),"\t+","")]
|eval search_str="(index=".index.")"
|stats values(search_str) AS search_str
|eval to_return=mvjoin(search_str," OR ")
|return $to_return
]
BY index, host
|search NOT
(
[
|inputlookup table1
|stats count BY index, host
]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, I need your help to resolve the issue.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 19:16:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624758#M217181</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2022-12-19T19:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to find results present in index and not in lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624769#M217189</link>
      <description>&lt;P&gt;You can approach it from a different side completely.&lt;/P&gt;&lt;P&gt;Instead of building a condition for your search, you can just search across all data (it's tstats so it should be reasonably quick) and filter out the "bad" entries&lt;/P&gt;&lt;PRE&gt;| tstats count where index IN ("your","set","of","indexes","or","*") host IN ("another","set","or","*") by host index&lt;BR /&gt;| lookup yourlookup index host OUTPUT index as found_index&lt;BR /&gt;| where NOT index=found_index&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But you can still build your search by excluding from tstats directly&lt;/P&gt;&lt;PRE&gt;| tstats count where&lt;BR /&gt;   [ | inputlookup yourlookup&lt;BR /&gt;     | table index ] NOT&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [ | inputlookup yourlookup&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | table host index ]&lt;BR /&gt;BY host index&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 22:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624769#M217189</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-12-19T22:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to find results present in index and not in lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624770#M217190</link>
      <description>&lt;P&gt;The first subsearch appears to be doing a lot of unnecessary work that could be replaced by the format command.&lt;/P&gt;&lt;P&gt;The second subsearch is telling Splunk to look for the index, host, and count fields, but the main search has only index and host.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats fillnull_value="unknown" count AS event_count
WHERE
[
  | inputlookup table1
  | fields index
  | format
]
BY index, host
|search NOT
[
  | inputlookup table1
  | fields index, host
  | format
]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 19 Dec 2022 22:03:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624770#M217190</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-12-19T22:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find results present in index and not in lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624882#M217227</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for sharing your inputs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I observed that even though I was using tstats command, it was taking a long time to load the results, considering the long list of index values and their respective hosts.&amp;nbsp; And I had to build a dashboard to give the results to end users.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To overcome the slowness of fetching results on the dashboard, I did following: -&lt;/P&gt;&lt;P&gt;1. Created a new lookup table.&lt;/P&gt;&lt;P&gt;2. Built a report with the tstats command and added the results to the new lookup table.&lt;/P&gt;&lt;P&gt;3. Scheduled the report to run after every 5 minutes and refresh the lookup table periodically.&lt;/P&gt;&lt;P&gt;4. Use the lookup table to fetch and display the results on the dashboard.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please share your views on the above approach and if you have suggestions to improve the same.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 18:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624882#M217227</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2022-12-20T18:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to find results present in index and not in lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624901#M217231</link>
      <description>&lt;P&gt;Sometimes the &lt;FONT face="courier new,courier"&gt;tstats&lt;/FONT&gt; command takes a while.&lt;/P&gt;&lt;P&gt;Your workaround is fine, but there's no need for another lookup table.&amp;nbsp; Schedule a search to run and output results using a &lt;FONT face="courier new,courier"&gt;table&lt;/FONT&gt; command.&amp;nbsp; Splunk will save the results as it normally does.&amp;nbsp; Have the dashboard invoke the search using the &lt;FONT face="courier new,courier"&gt;loadjob&lt;/FONT&gt; command.&amp;nbsp; Splunk will load the results of the most recent run of the saved search.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 21:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/624901#M217231</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-12-20T21:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to find results present in index and not in lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/625131#M217305</link>
      <description>&lt;P&gt;Thank you for sharing your inputs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 20:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-results-present-in-index-and-not-in-lookup-table/m-p/625131#M217305</guid>
      <dc:creator>Taruchit</dc:creator>
      <dc:date>2022-12-22T20:18:34Z</dc:date>
    </item>
  </channel>
</rss>

