<?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: SPL Question: Using Lookup field values in a tstats search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683351#M233353</link>
    <description>&lt;P&gt;The reason why your subsearch is taking a long time is _probably_ due to the volume of hosts, because using a large X=Y OR A=B OR C=D expression in the search can be very slow to get parsed and setup, hence the lookup option can often be the better option.&lt;/P&gt;&lt;P&gt;The second way is fundamentally on a different planet to your concept of the previous search. Using join in itself is limited and using join+inputlookup is a completely wrong way to use lookups. The lookup command is designed to enrich data with results from a lookup. If a result cannot be found in the lookup, you will not get results from the lookup and you can validate that state.&lt;/P&gt;&lt;P&gt;Have you tried it?&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2024 22:44:57 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2024-04-04T22:44:57Z</dc:date>
    <item>
      <title>SPL Question: Using Lookup field values in a tstats search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683112#M233309</link>
      <description>&lt;P&gt;Hi all, getting to grips with SPL and would be forever grateful if someone could lend their brain for the below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've got the lookup in the format below:&lt;/P&gt;
&lt;P&gt;(Fields) --&amp;gt;&amp;nbsp; host, os, os version&lt;/P&gt;
&lt;P&gt;-----------------------------------------&lt;/P&gt;
&lt;P&gt;(Values) ---&amp;gt; Server01, Windows, Windows Server 2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in my case, this lookup has 3000 field values, I want to know their source values in Splunk (This lookup was generated by a match condition with another, so I KNOW that these hosts are present in my Splunk env)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I basically need a way to do the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;"| tstats values(sources) where index=* host=(WHATEVER IS IN MY LOOKUP HOST FIELD) by index, host"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i can't seem to find a way, I did try to originally match the below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| tstats values(source) where index=* by host, index

| join type=inner host

| [|inputlookup mylookup.csv | fields host | dedup host]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my results were too large to handle by Splunk, &lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;plz help&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 23:14:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683112#M233309</guid>
      <dc:creator>IAskALotOfQs</dc:creator>
      <dc:date>2024-04-03T23:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: SPL Question: Using Lookup field values in a tstats search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683114#M233311</link>
      <description>&lt;P&gt;Forget join - that is not a splunk way of doing things.&lt;/P&gt;&lt;P&gt;Use either a subsearch or a lookup - they may perform differently depending on data volumes, but you can do this&lt;/P&gt;&lt;P&gt;Subsearch method&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats values(sources) where index=* 
  [ | inputlookup mylookjup.csv | fields host | dedup host ]
 by index, host&lt;/LI-CODE&gt;&lt;P&gt;The subsearch will effectively return with ( host=x OR host=y OR host=z...) which is then used in the outer search.&lt;/P&gt;&lt;P&gt;Lookup method&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats values(sources) where index=* by index, host
| lookup mylookjup.csv host&lt;/LI-CODE&gt;&lt;P&gt;This gets ALL the data from the indexes and then does the lookup to get the OS details.&lt;/P&gt;&lt;P&gt;You can always do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where isnull(os) &lt;/LI-CODE&gt;&lt;P&gt;which will then show those hosts that do not exist in the lookup that are found in the data.&lt;/P&gt;&lt;P&gt;Note that the lookup CSV will be case sensitive - if you want to make it insensitive, make a lookup definition and configure it as case insensitive&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 23:40:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683114#M233311</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-04-03T23:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: SPL Question: Using Lookup field values in a tstats search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683121#M233313</link>
      <description>&lt;P&gt;Appreciate your speedy reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've just checked to see how by "subsearch" would run, I've changed my time picker to 30 mins and it hasn't run anything, its been stuck at 0 of 0 events matched with bar flashing....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, the second way "lookup" uses the same concept of my previous search, I will most likely run into a "VV data is too large for serialization" error&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 00:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683121#M233313</guid>
      <dc:creator>IAskALotOfQs</dc:creator>
      <dc:date>2024-04-04T00:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: SPL Question: Using Lookup field values in a tstats search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683127#M233314</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I've just checked to see how by "subsearch" would run, I've changed my time picker to 30 mins and it hasn't run anything, its been stuck at 0 of 0 events matched with&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The question is: have you manually verified that your data in the new time period actually contain matching hosts? &amp;nbsp;Here is a quick way to confirm that the subsearch method works.&lt;/P&gt;&lt;P&gt;1. Select a couple hosts that you know some events match in this time period match. &amp;nbsp;Say, &lt;EM&gt;host1&lt;/EM&gt; and &lt;EM&gt;host2&lt;/EM&gt;. &amp;nbsp;Run this search with the chosen time picker.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats values(source)
  where index=* (host="host1" OR host="host2")
  earliest=-30m@h latest=-0@h
  by host, index&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this search gives you no output, you need to find another couple of hosts till you can get non-zero output. (Hint: it is best to run all tests with a time boundaries where you know your tests will not cross. &amp;nbsp;I would suggesting using fixed earliest/latest rather than time picker. &amp;nbsp;For example, earliest=-30m@h latest=-0m@h)&lt;/P&gt;&lt;P&gt;2. Make sure that &lt;EM&gt;host1&lt;/EM&gt; and &lt;EM&gt;host2&lt;/EM&gt; exist in mylookup.csv with this search&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputookup mylookup.csv where host IN (host1, host2)
| fields host
| dedup host
| format&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;explained, the output should be something like&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;search&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="100%"&gt;( ( host="host1" ) OR ( host="host2" ) )&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If your result is different, that means mylookup.csv does not &lt;EM&gt;host1&lt;/EM&gt; and &lt;EM&gt;host2&lt;/EM&gt;. You then need to redesign/repopulate your lookup table.&lt;/P&gt;&lt;P&gt;3. Run the following combined search&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats values(source)
  where index=*
    [inputookup mylookup.csv where host IN (host1, host2)
    | fields host
    | dedup host]
  earliest=-30m@h latest=-0@h
  by host, index&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This search should give you the exact same results as the first one.&lt;/P&gt;&lt;P&gt;Then, you just remove there where clause in the subsearch.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Also, the second way "lookup" uses the same concept of my previous search, I will most likely run into a "VV data is too large for serialization" error&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Why do you say &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;'s lookup method uses the same concept as your join method? &amp;nbsp;Have you tried it? &amp;nbsp;It is totally different because it doesn't involve join. &amp;nbsp;Are you suggesting that&amp;nbsp;&lt;FONT face="courier new,courier"&gt;| tstats values(source) where index=* by host, index&lt;/FONT&gt; always gives you that error? What about&amp;nbsp;&lt;FONT face="courier new,courier"&gt;| tstats values(source) where index=* by host&lt;/FONT&gt;? What about&amp;nbsp;&lt;FONT face="courier new,courier"&gt;| tstats values(source) where index=*&lt;/FONT&gt;? &amp;nbsp;If these searches give you error, you may have some fundamental problem in your indexer. &amp;nbsp;No amount of SPL can save the day.&lt;/P&gt;&lt;P&gt;Given the chance, however, I would use the subsearch method because it is the fastest.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 02:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683127#M233314</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-04-04T02:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: SPL Question: Using Lookup field values in a tstats search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683351#M233353</link>
      <description>&lt;P&gt;The reason why your subsearch is taking a long time is _probably_ due to the volume of hosts, because using a large X=Y OR A=B OR C=D expression in the search can be very slow to get parsed and setup, hence the lookup option can often be the better option.&lt;/P&gt;&lt;P&gt;The second way is fundamentally on a different planet to your concept of the previous search. Using join in itself is limited and using join+inputlookup is a completely wrong way to use lookups. The lookup command is designed to enrich data with results from a lookup. If a result cannot be found in the lookup, you will not get results from the lookup and you can validate that state.&lt;/P&gt;&lt;P&gt;Have you tried it?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 22:44:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/SPL-Question-Using-Lookup-field-values-in-a-tstats-search/m-p/683351#M233353</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-04-04T22:44:57Z</dc:date>
    </item>
  </channel>
</rss>

