<?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: Generate values for IN search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656401#M226718</link>
    <description>&lt;P&gt;Thank you&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/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; - I'd accept both as the solution if I could as I learned about the &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; &lt;/FONT&gt;and &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;format&lt;/STRONG&gt; &lt;/FONT&gt;commands from you both. I accepted &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; &lt;/FONT&gt;as the solution since I wanted to use the &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;IN&lt;/STRONG&gt; &lt;/FONT&gt;search, and couldn't format the &lt;STRONG&gt;&lt;FONT face="simsun,hei"&gt;format &lt;/FONT&gt;&lt;/STRONG&gt;command to remove the column names from the generated string. Not sure this is right, but I ended up having to use an &lt;STRONG&gt;&lt;FONT face="simsun,hei"&gt;eval&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;command to append quotesa and commas to my values, prior to the &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; &lt;/FONT&gt;statement. In the end, it was something like...&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;index=syslog src_ip IN ( 
  [ 
    | tstats count from datamodel=Random by ips 
    | stats values(ips) as IP 
    | eval IP = "\"".IP."\","
    | return $IP
  ]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Thanks again!&lt;/P&gt;</description>
    <pubDate>Fri, 01 Sep 2023 09:53:30 GMT</pubDate>
    <dc:creator>makelovenotwar</dc:creator>
    <dc:date>2023-09-01T09:53:30Z</dc:date>
    <item>
      <title>Generate values for IN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656321#M226691</link>
      <description>&lt;P class="lia-align-left"&gt;How do I use a search to generate values to use inside of an &lt;STRONG&gt;IN&lt;/STRONG&gt; search? For example:&lt;/P&gt;&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;index=syslog src_ip IN ( | tstats count from datamodel=Random by ips | stats values(ips) as IP | eval IP = mvjoin(IP, ",")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the method above but it's not working. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 20:08:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656321#M226691</guid>
      <dc:creator>makelovenotwar</dc:creator>
      <dc:date>2023-08-31T20:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values for IN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656330#M226693</link>
      <description>&lt;P&gt;Don't bother.&amp;nbsp; &lt;FONT face="courier new,courier"&gt;IN&lt;/FONT&gt; optimizes to a series of &lt;FONT face="courier new,courier"&gt;OR&lt;/FONT&gt;s so just start with that.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslog [ | tstats count from datamodel=Random by ips | rename ips as src_ip | fields src_ip | format ]&lt;/LI-CODE&gt;&lt;P&gt;The subsearch will run first and use the &lt;FONT face="courier new,courier"&gt;format&lt;/FONT&gt; command to produce a string like "(src_ip=1.2.3.4 OR src_ip=2.3.4.5)" which will become part of the main search.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 20:21:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656330#M226693</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-08-31T20:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values for IN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656368#M226710</link>
      <description>&lt;P&gt;What&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;is correct, but technically it's possible to format the return value so it can be used in the IN statement - your problem is that you are not crafting a subsearch - you're missing the [] subsearch brackets&amp;nbsp; - but you could do it like this - but you wouldn't really want to...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=syslog src_ip IN ( 
  [ 
    | tstats count from datamodel=Random by ips 
    | stats values(ips) as IP 
``` You could technically do this, but it's not necessary
    | eval IP = mvjoin(IP, ",")```
``` Use this return $ statement to return a space separated string 
    but you could technically use the mvjoin and have a comma separated one```
    | return $IP
  ]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 06:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656368#M226710</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-09-01T06:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Generate values for IN search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656401#M226718</link>
      <description>&lt;P&gt;Thank you&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/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp; - I'd accept both as the solution if I could as I learned about the &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; &lt;/FONT&gt;and &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;format&lt;/STRONG&gt; &lt;/FONT&gt;commands from you both. I accepted &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; &lt;/FONT&gt;as the solution since I wanted to use the &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;IN&lt;/STRONG&gt; &lt;/FONT&gt;search, and couldn't format the &lt;STRONG&gt;&lt;FONT face="simsun,hei"&gt;format &lt;/FONT&gt;&lt;/STRONG&gt;command to remove the column names from the generated string. Not sure this is right, but I ended up having to use an &lt;STRONG&gt;&lt;FONT face="simsun,hei"&gt;eval&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;command to append quotesa and commas to my values, prior to the &lt;FONT face="simsun,hei"&gt;&lt;STRONG&gt;return&lt;/STRONG&gt; &lt;/FONT&gt;statement. In the end, it was something like...&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;index=syslog src_ip IN ( 
  [ 
    | tstats count from datamodel=Random by ips 
    | stats values(ips) as IP 
    | eval IP = "\"".IP."\","
    | return $IP
  ]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 09:53:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Generate-values-for-IN-search/m-p/656401#M226718</guid>
      <dc:creator>makelovenotwar</dc:creator>
      <dc:date>2023-09-01T09:53:30Z</dc:date>
    </item>
  </channel>
</rss>

