<?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: Is there any way via REST to get JSON raw data from Splunk for a given query? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165724#M33608</link>
    <description>&lt;P&gt;Most specifically the output_mode tag&lt;/P&gt;

&lt;P&gt;curl -k -u admin:changeme --data-urlencode search="search index=main earliest=-1m latest=now | timechart count by sourcetype" -d &lt;STRONG&gt;"output_mode=json"&lt;/STRONG&gt; &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Dec 2014 19:55:58 GMT</pubDate>
    <dc:creator>dolivasoh</dc:creator>
    <dc:date>2014-12-29T19:55:58Z</dc:date>
    <item>
      <title>Is there any way via REST to get JSON raw data from Splunk for a given query?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165722#M33606</link>
      <description>&lt;P&gt;Is there any way how I can get JSON raw data from Splunk for a given query?&lt;/P&gt;

&lt;P&gt;Consider the following timechart query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* earliest=&amp;lt;from_time&amp;gt; latest=&amp;lt;to_time&amp;gt; | timechart  span=1s count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Key things in the query are: 1. Start/End Time, 2. Time Span (say sec) and 3. Value (say count)&lt;/P&gt;

&lt;P&gt;The expected JSON response would be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"fields":["_time","count","_span"], "rows":[["2014-12-25T00:00:00.000-06:00","1460981","1"], ..., ["2014-12-25T01:00:00.000-06:00","536889","1"]]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the XHR (ajax calls) for the output_mode=json_rows calls. This requires session and authentication setups.&lt;/P&gt;

&lt;P&gt;I’m looking for a RESTful implementation of the same with authentication.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:30:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165722#M33606</guid>
      <dc:creator>jibiuthaman</dc:creator>
      <dc:date>2020-09-28T18:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way via REST to get JSON raw data from Splunk for a given query?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165723#M33607</link>
      <description>&lt;P&gt;Maybe check out the REST API Basic Tutorial &lt;A href="http://dev.splunk.com/view/basic-tutorial/SP-CAAADQT"&gt;http://dev.splunk.com/view/basic-tutorial/SP-CAAADQT&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2014 19:48:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165723#M33607</guid>
      <dc:creator>dolivasoh</dc:creator>
      <dc:date>2014-12-29T19:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way via REST to get JSON raw data from Splunk for a given query?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165724#M33608</link>
      <description>&lt;P&gt;Most specifically the output_mode tag&lt;/P&gt;

&lt;P&gt;curl -k -u admin:changeme --data-urlencode search="search index=main earliest=-1m latest=now | timechart count by sourcetype" -d &lt;STRONG&gt;"output_mode=json"&lt;/STRONG&gt; &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs/export"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Dec 2014 19:55:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165724#M33608</guid>
      <dc:creator>dolivasoh</dc:creator>
      <dc:date>2014-12-29T19:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way via REST to get JSON raw data from Splunk for a given query?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165725#M33609</link>
      <description>&lt;P&gt;If you're looking for a javascript call... here's an example using axios (an npm package i use in my react apps - fetch will also work)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;const base_url = ''https://yoursplunkserver.com/servicesNS/admin/search/search/jobs/export";
const auth = {username: 'username', password: 'password'};
const search = 'savedsearch yourSavedSearchName';
const params={'output_mode': 'json_cols', search: search}; //no es6 used for clarity

axios.get(base_url, {auth: auth, params: params})
.then((response) =&amp;gt; {
//do something with your data
})
.catch((err) =&amp;gt; {
//sth went wrong
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps someone&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 03:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-any-way-via-REST-to-get-JSON-raw-data-from-Splunk-for-a/m-p/165725#M33609</guid>
      <dc:creator>AlisonHaire</dc:creator>
      <dc:date>2018-05-18T03:11:16Z</dc:date>
    </item>
  </channel>
</rss>

