<?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 does search via REST API only outputs internal debug data? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88968#M18465</link>
    <description>&lt;P&gt;Ok, our developer switched to shell and ran the following curl:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl --get -s -k -u fkt_foofoo:foofoo4u &lt;A href="https://foosplunknet.de:8089/servicesNS/admin/search/search/jobs/export" target="test_blank"&gt;https://foosplunknet.de:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt; -d output_mode=json -d exec_mode=oneshot -d earliest_time=-60m -d latest_time=now -d preview=false --data-urlencode search="search foo_group=live source="/tomcat/logs/logling.log" ltag="service/authenticate" | stats count(visitor) as visitor" |jq -r '.result | .visitor'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;from the shell and the Splunk GUI and in both cases we get the same result.&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Thomas&lt;/P&gt;</description>
    <pubDate>Wed, 10 Apr 2013 15:17:08 GMT</pubDate>
    <dc:creator>tpaulsen</dc:creator>
    <dc:date>2013-04-10T15:17:08Z</dc:date>
    <item>
      <title>Why does search via REST API only outputs internal debug data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88967#M18464</link>
      <description>&lt;P&gt;Hi, we have a Splunk 5 system running. When we try to do a search via the REST API, we get debug output information back. When we do the search a second time, we get the results of the search. What are we doing wrong here?&lt;/P&gt;

&lt;P&gt;Splunk SEARCH:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/var/opt/tomcat/logs/tomcat_access.log" fooo_group=foofoofoo | timechart span=10s avg(runtime) by fooo_tical
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;CODE:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    package de.fooo.jenkinsci.plugins.splunker;

    import de.fooo.jenkinsci.utils.IOMagic;
    import org.apache.commons.io.FilenameUtils;

    import java.io.File;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;

    final class SplunkSearch {

            private static final String SPLUNKRESULTDATAFILENAME = "splunkresultdata.csv";

            // 2013-02-08T11:40:58-0100
            private static final DateFormat splunkDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ");

           private final String splunkServerUrl;
           private final String userName;
           private final String password;

           SplunkSearch(String splunkServerUrl, String userName, String password) throws Exception {
                   this.splunkServerUrl = splunkServerUrl;
                   this.userName = userName;
                   this.password = password;

                   // TODO test connection
                   // curl -k -u fkt_foofoo:splunkfooword
                   // &lt;A href="https://fooo-splunk-foonet.de:8089/services/authentication/users" target="test_blank"&gt;https://fooo-splunk-foonet.de:8089/services/authentication/users&lt;/A&gt;
           }

           File search(String search, Date from, Date now) throws Exception {
                   File datafile;
                   if (search.startsWith("SELFTEST")) {
                           datafile = IOMagic.saveFileFromClasspath("/scripts/statistic/demodata/" + search + ".csv", search, ".csv");
                   } else {
                           System.out.println("---------------------------------------------------------------- 1");
                           List&amp;lt;String&amp;gt; command = new ArrayList&amp;lt;String&amp;gt;();
                           command.add("curl");
                           command.add("-vs");
                           command.add("-k");
                           command.add("-u");
                           command.add(userName + ":" + password);
                           command.add(splunkServerUrl);
                           command.add("-d");
                           command.add("output_mode=csv");
                           command.add("--data-urlencode");
                           command.add("search=search " + search);
                           command.add("-d");
                           command.add("earliest_time=\"" + splunkDateFormat.format(from) + "\"");
                           command.add("-d");
                           command.add("latest_time=\"" + splunkDateFormat.format(now) + "\"");
                           command.add("-d");
                           command.add("exec_mode=\"oneshot\"");
                           command.add("-o");
                           File tmpfile = File.createTempFile(FilenameUtils.getBaseName(SPLUNKRESULTDATAFILENAME),
                                           "." + FilenameUtils.getExtension(SPLUNKRESULTDATAFILENAME));
                           command.add(tmpfile.getAbsolutePath());

                           ProcessBuilder pb = new ProcessBuilder();
                           pb.command(command);
                           pb.start();
                           try {
                                   Thread.sleep(10000);
                           } catch (InterruptedException e) {
                                   e.printStackTrace();
                           }
                           // Avoid empty first line
                           datafile = File.createTempFile(FilenameUtils.getBaseName(SPLUNKRESULTDATAFILENAME),
                                           "." + FilenameUtils.getExtension(SPLUNKRESULTDATAFILENAME));
                           IOMagic.removeEmptyLines(tmpfile, datafile);
                   }
                   if (datafile.length() == 0) {
                           throw new Exception("Data file from Splunk is empty.");
                   }
                   return datafile;
           }

   }
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2013 14:09:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88967#M18464</guid>
      <dc:creator>tpaulsen</dc:creator>
      <dc:date>2013-04-09T14:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why does search via REST API only outputs internal debug data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88968#M18465</link>
      <description>&lt;P&gt;Ok, our developer switched to shell and ran the following curl:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl --get -s -k -u fkt_foofoo:foofoo4u &lt;A href="https://foosplunknet.de:8089/servicesNS/admin/search/search/jobs/export" target="test_blank"&gt;https://foosplunknet.de:8089/servicesNS/admin/search/search/jobs/export&lt;/A&gt; -d output_mode=json -d exec_mode=oneshot -d earliest_time=-60m -d latest_time=now -d preview=false --data-urlencode search="search foo_group=live source="/tomcat/logs/logling.log" ltag="service/authenticate" | stats count(visitor) as visitor" |jq -r '.result | .visitor'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;from the shell and the Splunk GUI and in both cases we get the same result.&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Thomas&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2013 15:17:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88968#M18465</guid>
      <dc:creator>tpaulsen</dc:creator>
      <dc:date>2013-04-10T15:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why does search via REST API only outputs internal debug data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88969#M18466</link>
      <description>&lt;P&gt;Hello, I have the same issue and it seems that this happens when the output_mode is set to 'csv' . When i issue the same request, adding the ' | table *  ' command at the end of the search, I get all the information, but it is three times slower. Can you please take a look?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:53:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-does-search-via-REST-API-only-outputs-internal-debug-data/m-p/88969#M18466</guid>
      <dc:creator>artemidas</dc:creator>
      <dc:date>2018-01-30T15:53:23Z</dc:date>
    </item>
  </channel>
</rss>

