<?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 Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214292#M62838</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to do a real-time Splunk search using the REST API. The endpoint I am sending a request to is &lt;CODE&gt;services/search/jobs/export&lt;/CODE&gt; and if I understand the documentation correctly, I should be getting a stream of events that match my search. My problem is that I am not receiving ANY data back. I am 100% sure the events are happening and getting into Splunk, because I can see them through Splunk Web.&lt;/P&gt;

&lt;P&gt;More info about the request I am making: &lt;BR /&gt;
 - &lt;STRONG&gt;earliest_time&lt;/STRONG&gt; and &lt;STRONG&gt;latest_time&lt;/STRONG&gt; are set to &lt;STRONG&gt;rt&lt;/STRONG&gt;&lt;BR /&gt;
 - &lt;STRONG&gt;search_mode&lt;/STRONG&gt; is set to &lt;STRONG&gt;realtime&lt;/STRONG&gt;. I tried every possible value and still I couldn't get anything back.&lt;/P&gt;

&lt;P&gt;The only way I get some data back is if I set the &lt;STRONG&gt;auto_cancel&lt;/STRONG&gt; parameter to some value. After the search cancels, I get the accumulated results back. What I don't understand is why am I not getting the data streamed back? What am I missing?&lt;/P&gt;

&lt;P&gt;I would be really grateful if someone points me in the right direction. Thanks! &lt;/P&gt;</description>
    <pubDate>Sun, 07 Aug 2016 19:58:48 GMT</pubDate>
    <dc:creator>sk4l</dc:creator>
    <dc:date>2016-08-07T19:58:48Z</dc:date>
    <item>
      <title>Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214292#M62838</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to do a real-time Splunk search using the REST API. The endpoint I am sending a request to is &lt;CODE&gt;services/search/jobs/export&lt;/CODE&gt; and if I understand the documentation correctly, I should be getting a stream of events that match my search. My problem is that I am not receiving ANY data back. I am 100% sure the events are happening and getting into Splunk, because I can see them through Splunk Web.&lt;/P&gt;

&lt;P&gt;More info about the request I am making: &lt;BR /&gt;
 - &lt;STRONG&gt;earliest_time&lt;/STRONG&gt; and &lt;STRONG&gt;latest_time&lt;/STRONG&gt; are set to &lt;STRONG&gt;rt&lt;/STRONG&gt;&lt;BR /&gt;
 - &lt;STRONG&gt;search_mode&lt;/STRONG&gt; is set to &lt;STRONG&gt;realtime&lt;/STRONG&gt;. I tried every possible value and still I couldn't get anything back.&lt;/P&gt;

&lt;P&gt;The only way I get some data back is if I set the &lt;STRONG&gt;auto_cancel&lt;/STRONG&gt; parameter to some value. After the search cancels, I get the accumulated results back. What I don't understand is why am I not getting the data streamed back? What am I missing?&lt;/P&gt;

&lt;P&gt;I would be really grateful if someone points me in the right direction. Thanks! &lt;/P&gt;</description>
      <pubDate>Sun, 07 Aug 2016 19:58:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214292#M62838</guid>
      <dc:creator>sk4l</dc:creator>
      <dc:date>2016-08-07T19:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214293#M62839</link>
      <description>&lt;P&gt;Hi sk4l,&lt;/P&gt;

&lt;P&gt;First thing that should not work the way you think is the &lt;CODE&gt;rest&lt;/CODE&gt; command; &lt;CODE&gt;rest&lt;/CODE&gt; cannot be used in real-time searches and give this error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Error in 'rest' command: This command is not supported in a real-time search
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the other thing is your used rest end point &lt;CODE&gt;/search/jobs/export&lt;/CODE&gt;. I'm not sure if this is correct because the docs &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.2/RESTREF/RESTsearch#search.2Fjobs.2Fexport"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.2/RESTREF/RESTsearch#search.2Fjobs.2Fexport&lt;/A&gt; mention &lt;CODE&gt;/services/search/jobs/export&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 00:06:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214293#M62839</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-08T00:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214294#M62840</link>
      <description>&lt;P&gt;Hi, thanks for the response!&lt;/P&gt;

&lt;P&gt;I didn't mean a rest command, but the REST-ful API. I am also using the endpoint you suggested.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 07:17:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214294#M62840</guid>
      <dc:creator>sk4l</dc:creator>
      <dc:date>2016-08-08T07:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214295#M62841</link>
      <description>&lt;P&gt;Hmmm, still the &lt;CODE&gt;rest&lt;/CODE&gt; command uses the REST API to show the information and I never heard / saw a REST API call being made in real-time.....maybe you want to elaborate your use cases a bit more?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Aug 2016 20:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214295#M62841</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-08T20:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214296#M62842</link>
      <description>&lt;P&gt;I want to be able to monitor the progress of some infrastructure commands. The command's chain of activated services produces lots of Splunk logs, which I want to see as they arrive. That's why I want to start a real-time search, activate the command, and have the results arrive at an endpoint of my choice. &lt;/P&gt;

&lt;P&gt;The big problem here is that the logs are visible in Splunk Web almost instantly, but don't get streamed to my real-time search for at least another 30 seconds.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 14:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214296#M62842</guid>
      <dc:creator>sk4l</dc:creator>
      <dc:date>2016-08-09T14:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214297#M62843</link>
      <description>&lt;P&gt;How are you making the request? Have you tested with curl?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 16:29:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214297#M62843</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-08-11T16:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214298#M62844</link>
      <description>&lt;P&gt;Yes, cURL gives me results delayed with around 30-40 seconds. Node.js doesn't give me ANY results, which is weird, considering I am using the standard request from the documentation. I've re-checked my code 10 times.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;function startRealTimeSearch(searchQuery, callback) {

  // I've replaced the data with placeholders
  const options = {
    hostname: 'splunk_instance_address',
    port: 'port_number',
    path: '/services/search/jobs/export',
    method: 'POST',

    headers: {
      'Authorization': 'Basic base64_encoded_data'
    }
  };

  // POST body
  let search_body = qs.stringify({
    'search': searchQuery,
    'earliest_time': 'rt',
    'latest_time': 'rt',
    'output_mode': 'json'
  });


  // HTTPS POST request to Splunk that starts the RT search
  let searchRequestToSplunk = https.request(options, function onResponse(res) {

      let receivedData = '';

      // The stream of events should be received here.
      res.on('data', (chunk) =&amp;gt; {
        receivedData += chunk;
        console.log(`Received: ${receivedData}`);
      });

      res.on('end', () =&amp;gt; {
        console.log(`Stream ended.`);
      });


  });
  // Send the POST request to the Splunk API
  searchRequestToSplunk.write(search_body);
  searchRequestToSplunk.end();

  // Receive request errors here
  searchRequestToSplunk.on('error', (err) =&amp;gt; {
    console.error(err.message);
  });

}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 13:06:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214298#M62844</guid>
      <dc:creator>sk4l</dc:creator>
      <dc:date>2016-08-12T13:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting any search results using the REST API to send a request to the /search/jobs/export endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214299#M62845</link>
      <description>&lt;P&gt;OK, since you are using node, I did a blog post on export from node. The post is &lt;A href="http://blogs.splunk.com/2014/09/04/exporting-search-results-with-javascript/"&gt;here&lt;/A&gt;. I use a slightly different approach using the request module and pipes. &lt;/P&gt;

&lt;P&gt;Can you try it out and see if it works, and then maybe tweak it to your use case?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 19:34:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-any-search-results-using-the-REST-API-to/m-p/214299#M62845</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-08-12T19:34:20Z</dc:date>
    </item>
  </channel>
</rss>

