<?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: search using the Splunk API to get back a single result(not streaming) without using a saved search or SID? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477286#M192691</link>
    <description>&lt;P&gt;Glad that it worked.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2019 08:35:15 GMT</pubDate>
    <dc:creator>harsmarvania57</dc:creator>
    <dc:date>2019-09-06T08:35:15Z</dc:date>
    <item>
      <title>search using the Splunk API to get back a single result(not streaming) without using a saved search or SID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477282#M192687</link>
      <description>&lt;P&gt;can we run a search using the Splunk API to get back a single result(not streaming) without using a saved search or SID?&lt;/P&gt;

&lt;P&gt;I tried export like below which is giving streamed output, i want single result&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -k -u admin:admin &lt;A href="https://searchhead:8089/services/search/jobs/export" target="test_blank"&gt;https://searchhead:8089/services/search/jobs/export&lt;/A&gt;  -d search="search *| stats max(_time) AS _time BY "pctIdle" | head 1|sort 0 - _time | rename "pctIdle" AS Value" -d output_mode=json&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I tried post like this , giving me SID( i dont wnt to use SID r saved search )&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;curl -k -u admin:admin &lt;A href="https://searchhead:8089/servicesNS/admin/search/search/jobs" target="test_blank"&gt;https://searchhead:8089/servicesNS/admin/search/search/jobs&lt;/A&gt; --data-urlencode search="search * | stats max(_time) AS _time BY "pctIdle" | sort 0 - _time | head 1|rename "pctIdle" AS Value " -d id=mysearch_0215194643 -d max_count=50000 -d status_buckets=300&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Any other way to get results with out SID r saved search?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 13:16:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477282#M192687</guid>
      <dc:creator>vasanthi77</dc:creator>
      <dc:date>2019-09-05T13:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: search using the Splunk API to get back a single result(not streaming) without using a saved search or SID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477283#M192688</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You can achieve this with your first search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:admin &lt;A href="https://searchhead:8089/services/search/jobs/export" target="test_blank"&gt;https://searchhead:8089/services/search/jobs/export&lt;/A&gt; -d search="search *| stats max(_time) AS _time BY "pctIdle" | head 1|sort 0 - _time | rename "pctIdle" AS Value" -d output_mode=json
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but the problem is you didn't mention any time frame in your search and due to that it will search &lt;CODE&gt;All Time&lt;/CODE&gt; and by default &lt;CODE&gt;preview=true&lt;/CODE&gt; so it will preview result constantly as splunk is searching more data. &lt;/P&gt;

&lt;P&gt;So you can try below  command , in which you can specify &lt;CODE&gt;earliest_time&lt;/CODE&gt; and &lt;CODE&gt;latest_time&lt;/CODE&gt;&amp;amp; disable preview.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:admin &lt;A href="https://searchhead:8089/services/search/jobs/export" target="test_blank"&gt;https://searchhead:8089/services/search/jobs/export&lt;/A&gt; -d search="search *| stats max(_time) AS _time BY "pctIdle" | head 1|sort 0 - _time | rename "pctIdle" AS Value" -d output_mode=json -d preview=false -d earliest_time=-15m -d latest_time=now
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 15:02:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477283#M192688</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-09-05T15:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: search using the Splunk API to get back a single result(not streaming) without using a saved search or SID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477284#M192689</link>
      <description>&lt;P&gt;@harsmarvania57    getting this error response&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;response&amp;gt;
  &amp;lt;messages&amp;gt;
  &amp;lt;msg type="FATAL"&amp;gt;
  Invalid sid: export -d search="search *| stats max(_time) AS _time BY "pctIdle" | head 1|sort 0 - _time | rename "pctIdle" AS Value" -d output_mode=json -d preview=false -d earliest_time=-15m -d latest_time=now
  &amp;lt;/msg&amp;gt;
  &amp;lt;/messages&amp;gt;
  &amp;lt;/response&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Sep 2019 23:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477284#M192689</guid>
      <dc:creator>vasanthi77</dc:creator>
      <dc:date>2019-09-05T23:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: search using the Splunk API to get back a single result(not streaming) without using a saved search or SID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477285#M192690</link>
      <description>&lt;P&gt;@harsmarvania57  Thanks for responding. It working as expected .&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;A href="https://search" target="test_blank"&gt;https://search&lt;/A&gt; head:8089/services/search/jobs/export?search=search *| stats max(_time) AS _time BY "pctIdle" | head 1|sort 0 - _time | rename "pctIdle" AS Value&amp;amp;preview=false&amp;amp;earliest_time=-2m&amp;amp;latest_time=now&amp;amp;output_mode=json&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 01:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477285#M192690</guid>
      <dc:creator>vasanthi77</dc:creator>
      <dc:date>2019-09-06T01:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: search using the Splunk API to get back a single result(not streaming) without using a saved search or SID?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477286#M192691</link>
      <description>&lt;P&gt;Glad that it worked.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 08:35:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-using-the-Splunk-API-to-get-back-a-single-result-not/m-p/477286#M192691</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-09-06T08:35:15Z</dc:date>
    </item>
  </channel>
</rss>

