<?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 subsearch fails with error &amp;quot;Unable to parse the search: Invalid search: AND AND&amp;quot; if it has to return endtime? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164031#M46591</link>
    <description>&lt;P&gt;Thank you! This fixed the issue.&lt;BR /&gt;
I still wonder why multiple AND statements didn't work - but I have a solution now!&lt;/P&gt;</description>
    <pubDate>Tue, 23 Dec 2014 23:16:51 GMT</pubDate>
    <dc:creator>gregnsk</dc:creator>
    <dc:date>2014-12-23T23:16:51Z</dc:date>
    <item>
      <title>Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164025#M46585</link>
      <description>&lt;P&gt;search returns valid results, but fails with Invalid search: AND AND if defined as subsearch:&lt;/P&gt;

&lt;H1&gt;1.    Search works ok:&lt;/H1&gt;

&lt;P&gt;source=nbstatus requestinghost=icsl2492 User=viefhwd starttime="12/09/2014:16:44:40" endtime="12/09/2014:16:45:40" | convert timeformat="%m/%d/%Y %H:%M:%S" mktime(StartTime) AS stime | convert timeformat="%m/%d/%Y:%H:%M:%S" ctime(stime) AS starttime | convert timeformat="%m/%d/%Y %H:%M:%S" mktime(FinishTime) AS entime | convert timeformat="%m/%d/%Y:%H:%M:%S" ctime(entime) AS endtime |table requestinghost User starttime endtime&lt;/P&gt;

&lt;P&gt;requestinghost User starttime endtime&lt;BR /&gt;
icsl2492    viefhwd 12/09/2014:16:45:37 12/09/2014:16:54:50&lt;/P&gt;

&lt;H1&gt;2.    If I define the above search as a subsearch to join with a different source, it fails:&lt;/H1&gt;

&lt;P&gt;src=license [search source=nbstatus requestinghost=icsl2492 User=viefhwd starttime="12/09/2014:16:44:40" endtime="12/09/2014:16:45:40" | convert timeformat="%m/%d/%Y %H:%M:%S" mktime(StartTime) AS stime | convert timeformat="%m/%d/%Y:%H:%M:%S" ctime(stime) AS starttime | convert timeformat="%m/%d/%Y %H:%M:%S" mktime(FinishTime) AS entime | convert timeformat="%m/%d/%Y:%H:%M:%S" ctime(entime) AS endtime |table requestinghost User starttime endtime]&lt;BR /&gt;
Error in 'search' command: Unable to parse the search: Invalid search: AND AND.&lt;BR /&gt;
The search job has failed due to an error. You may be able view the job in the Job Inspector.&lt;/P&gt;

&lt;H1&gt;3.    If I remove endtime only in the previous query – it works:&lt;/H1&gt;

&lt;P&gt;src=license [search source=nbstatus requestinghost=icsl2492 User=viefhwd starttime="12/09/2014:16:44:40" endtime="12/09/2014:16:45:40" | convert timeformat="%m/%d/%Y %H:%M:%S" mktime(StartTime) AS stime | convert timeformat="%m/%d/%Y:%H:%M:%S" ctime(stime) AS starttime | convert timeformat="%m/%d/%Y %H:%M:%S" mktime(FinishTime) AS entime | convert timeformat="%m/%d/%Y:%H:%M:%S" ctime(entime) AS endtime |table requestinghost User starttime]&lt;BR /&gt;
 12,004 events (before 12/12/14 3:26:47.781 PM)&lt;/P&gt;

&lt;H1&gt;4.    If I replace a subsearch from #2 with hard coded results of #1 I get the right results:&lt;/H1&gt;

&lt;P&gt;src=license requestinghost=icsl2492 User=viefhwd starttime="12/09/2014:16:45:37" endtime="12/09/2014:16:54:50" | chart count by result&lt;BR /&gt;
result&lt;BR /&gt;
count&lt;BR /&gt;
DENIED  20&lt;/P&gt;

&lt;P&gt;So what is wrong with my query #2?&lt;/P&gt;

&lt;P&gt;Thank you, &lt;BR /&gt;
   Gregory&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 09:10:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164025#M46585</guid>
      <dc:creator>gregnsk</dc:creator>
      <dc:date>2014-12-23T09:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164026#M46586</link>
      <description>&lt;P&gt;Granted I haven't had caffeine this morning but it appears you are taking a time, converting it to epoch, then back to a string and passing that up to your main search. If you want to use epoch you could just name the fields starttimeu and endtimeu and pass those up to your main search. &lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 12:26:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164026#M46586</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2014-12-23T12:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164027#M46587</link>
      <description>&lt;P&gt;I do this formatting to meet time format setting used at the second source. &lt;/P&gt;

&lt;P&gt;I have 2 sources: nbstatus and license. I want to get list of all events recorded from "license" input which happened on the same "requestinghost" for the same "user" and within the same "starttime-endtime" window as particular events in nbstatus source&lt;/P&gt;

&lt;P&gt;Search #1 returns nbstatus events I'm looking for. if I just apply it as a copy to "license" - I get what I need (item #4)&lt;BR /&gt;
But if I try to use it as a dynamic query, using subsearch - it fails (#2). If I loose the query (removing endtime) - this dynamic query works.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 13:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164027#M46587</guid>
      <dc:creator>gregnsk</dc:creator>
      <dc:date>2014-12-23T13:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164028#M46588</link>
      <description>&lt;P&gt;First thing to do is to check what your subsearch actually is.&lt;/P&gt;

&lt;P&gt;Take your search #1 and add &lt;CODE&gt;| format&lt;/CODE&gt; to the end of it. This will show you the syntax of what you're getting when you use it as a subsearch. If it doesn't look right, you can tweak it by passing parameters to &lt;CODE&gt;format&lt;/CODE&gt; to get the subsearch you want - see docs for details: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/format"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/format&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Once you figure out how to make it what you really want, you can add that &lt;CODE&gt;format&lt;/CODE&gt; clause to your actual subsearch.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 17:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164028#M46588</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-12-23T17:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164029#M46589</link>
      <description>&lt;P&gt;thank you. if I add format statement to search #1 I get:&lt;BR /&gt;
( ( User="viefhwd" AND endtime="12/09/2014:16:54:50" AND requestinghost="icsl2492" AND starttime="12/09/2014:16:45:37" ) )&lt;/P&gt;

&lt;P&gt;And indeed if I use it as a search parameters for src=license I get an error:&lt;BR /&gt;
src=license User="viefhwd" AND requestinghost="icsl2492" AND starttime="12/09/2014:16:45:37" AND endtime="12/09/2014:16:54:50"&lt;BR /&gt;
Error in 'search' command: Unable to parse the search: Invalid search: AND AND.&lt;/P&gt;

&lt;P&gt;However, if I remove all AND statements from the above, everything works:&lt;BR /&gt;
src=license User="viefhwd" requestinghost="icsl2492" starttime="12/09/2014:16:45:37" endtime="12/09/2014:16:54:50"&lt;/P&gt;

&lt;P&gt;What's wrong with the statement with several ANDs? what would be the right way to fix it?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 22:01:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164029#M46589</guid>
      <dc:creator>gregnsk</dc:creator>
      <dc:date>2014-12-23T22:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164030#M46590</link>
      <description>&lt;P&gt;I'm not sure what's wrong with the statement with several ANDs. It seems like that ought to work.&lt;/P&gt;

&lt;P&gt;However, since it's not, try working around it by adding a &lt;CODE&gt;format&lt;/CODE&gt; statement with six empty strings to your subsearch:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... [search... | format "" "" "" "" "" ""] ...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;That should remove all of the parentheses and conditionals, and you should just be left with your terms. (Try testing this by running #1 with the proposed &lt;CODE&gt;format&lt;/CODE&gt; statement and seeing what you get.)&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 22:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164030#M46590</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2014-12-23T22:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164031#M46591</link>
      <description>&lt;P&gt;Thank you! This fixed the issue.&lt;BR /&gt;
I still wonder why multiple AND statements didn't work - but I have a solution now!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 23:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164031#M46591</guid>
      <dc:creator>gregnsk</dc:creator>
      <dc:date>2014-12-23T23:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164032#M46592</link>
      <description>&lt;P&gt;Had a similar issue where the format looked like this.&lt;BR /&gt;
( ( accountNumber="xxxxxxxx" AND earliest="1441148065.377" AND latest="1441148665.377" ) )&lt;/P&gt;

&lt;P&gt;which produced the error: &lt;BR /&gt;
Error in 'search' command: Unable to parse the search: Invalid search: AND AND. &lt;/P&gt;

&lt;P&gt;adding |  format "" "" "" "" "" ""&lt;BR /&gt;
corrected the search format to:&lt;BR /&gt;
accountNumber="xxxxxxxx" earliest="1441148065.377" latest="1441148665.377" &lt;/P&gt;

&lt;P&gt;Hope Splunk will fix this in a future release. Seems like a common thing to want to modify the time constraints for earliest and latest passed back from the subsearch without doing advanced programming.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2015 23:40:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164032#M46592</guid>
      <dc:creator>bandit</dc:creator>
      <dc:date>2015-10-06T23:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why subsearch fails with error "Unable to parse the search: Invalid search: AND AND" if it has to return endtime?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164033#M46593</link>
      <description>&lt;P&gt;I ran into this exact issue today. I was looking to pass starttimeu and endtimeu values from a subsearch to the parent.  The values were based on the results of the subsearch so there was no way to add them to the parent at the start.  The solution was the format command and removing AND from the colseperator.  To correct the original search add &lt;CODE&gt;| format mvsep="mvseparator" "(" "(" " " ")" "OR" ")"&lt;/CODE&gt; before the end of the subsearch. &lt;/P&gt;

&lt;P&gt;This works since splunk implies AND to all search values. &lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 15:52:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-subsearch-fails-with-error-quot-Unable-to-parse-the-search/m-p/164033#M46593</guid>
      <dc:creator>aromanauskas</dc:creator>
      <dc:date>2016-05-06T15:52:39Z</dc:date>
    </item>
  </channel>
</rss>

