<?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: Why do I get &amp;quot;Unknown search command '3' when running this query? in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639964#M11446</link>
    <description>&lt;P&gt;Text inside square brackets ("[3]" in the query shown) is assumed to be a subsearch.&amp;nbsp; Subsearches must begin with a valid SPL command, which "3" is not.&lt;/P&gt;&lt;P&gt;It appears as though you are trying to use "[3]" as an array index into the results of the split function.&amp;nbsp; That's not how to do it, both because of the subsearch feature already mentioned and because Splunk doesn't have arrays.&lt;/P&gt;&lt;P&gt;Since split returns a multi-value field, use the mvindex function to choose one of the values.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval start_ip_long=tonumber(mvindex(split(start_ip,"."),3))
| eval end_ip_long=tonumber(mvindex(split(end_ip,"."),3))&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 14 Apr 2023 16:54:38 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-04-14T16:54:38Z</dc:date>
    <item>
      <title>Why do I get "Unknown search command '3' when running this query?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639959#M11445</link>
      <description>&lt;P&gt;I inputlookup ip_spywarelist.csv&lt;/P&gt;
&lt;P&gt;| eval ip_range=split(ip,"-")&lt;/P&gt;
&lt;P&gt;| eval start_ip=mvindex(ip_range, 0), end_ip=mvindex(ip_range, 1)&lt;/P&gt;
&lt;P&gt;| eval start_ip_long=tonumber(split(start_ip,"\\.")[3])&lt;/P&gt;
&lt;P&gt;| eval end_ip_long=tonumber(split(end_ip,"\\.")[3])&lt;/P&gt;
&lt;P&gt;| eval ip_list=mvrange(start_ip_long,end_ip_long)&lt;/P&gt;
&lt;P&gt;| mvexpand ip_list&lt;/P&gt;
&lt;P&gt;| eval ip_address=substr(start_ip,1,strlen(start_ip) -length(start_ip_long))&lt;/P&gt;
&lt;P&gt;| table ip_address&lt;/P&gt;
&lt;P&gt;Notes: When I run this query, I get "Unknown search command '3' (Please don't mind any typos, as I typed the query manually here). Why this query does NOT work?&amp;nbsp; The idea is to create a correlation search that would generate an alert if either the Src_ip or the dest_ip matches the IP within the IP range (in the ip field) . Since "ip_spywarelist.csv" has a field called "ip" that only contains IP ranges as values, I would like to search among all the IPs in each range not just the Start IP and end IP within the range (i.e: 2.60.13.132-2.60.13.137). I just wanted to verify if the query was working perfectly, before I include it in: index=* sourcetype=* [ | inputlookup ip_spywarelist.csv | ... The CSV file is provided by Splunk under "threat intel." The idea is to create a correlation search using that file which only provide the malicious IPs under IP range format.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 16:33:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639959#M11445</guid>
      <dc:creator>Kitag345</dc:creator>
      <dc:date>2023-04-14T16:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get "Unknown search command '3' when running this query?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639964#M11446</link>
      <description>&lt;P&gt;Text inside square brackets ("[3]" in the query shown) is assumed to be a subsearch.&amp;nbsp; Subsearches must begin with a valid SPL command, which "3" is not.&lt;/P&gt;&lt;P&gt;It appears as though you are trying to use "[3]" as an array index into the results of the split function.&amp;nbsp; That's not how to do it, both because of the subsearch feature already mentioned and because Splunk doesn't have arrays.&lt;/P&gt;&lt;P&gt;Since split returns a multi-value field, use the mvindex function to choose one of the values.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval start_ip_long=tonumber(mvindex(split(start_ip,"."),3))
| eval end_ip_long=tonumber(mvindex(split(end_ip,"."),3))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 14 Apr 2023 16:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639964#M11446</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-04-14T16:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why do I get "Unknown search command '3' when running this query?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639967#M11447</link>
      <description>&lt;P&gt;Thank you for your assistance. The query now works!&lt;/P&gt;&lt;P&gt;I also had to replace 'strlen' (which was a mistake as it's not supported by Splunk) by 'len'.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 17:21:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Why-do-I-get-quot-Unknown-search-command-3-when-running-this/m-p/639967#M11447</guid>
      <dc:creator>Kitag345</dc:creator>
      <dc:date>2023-04-14T17:21:46Z</dc:date>
    </item>
  </channel>
</rss>

