Dashboards & Visualizations

one shot search for Javascript SDK - not returning results

terryloar
Path Finder

I'm using the one shot search function, modeled on the @example in splunk-sdk-javascript/lib/service.js. It is all client-side.

When I execute the function below it returns a list of search parameters rather than the results themselves. What do I need to do to get the actual search results?

I would also like to know where to find the properties, in the Splunk documentation, for "results" such as "fields".

function performSearch() {
logIn();
var service = new splunkjs.Service();
var searchString = "search savedsearch=Billing_Base_Search";
var searchID = "billing_base_search";
var jobs = service.jobs();

jobs.search(searchString, {id: searchID}, function(err, newJob) {
console.log("CREATED: ", newJob.sid);
});

var delay = 5000;
window.setTimeout(doSearch, delay);

function doSearch() {
service.oneshotSearch(searchString, {id: searchID}, function(err, results) {
console.log("RESULT FIELDS: ", results.fields);
});
}

};

CREATED: billing_base_search

RESULT FIELDS: ["_cd", "_indextime", "_raw", "_serial", "_si", "_sourcetype", "_time", "host", "index", "linecount", "source", "sourcetype", "splunk_server"]

0 Karma

ChrisG
Splunk Employee
Splunk Employee

I put some documentation links (both reference and how-to for searching) in my answer to http://splunk-base.splunk.com/answers/54570/splunk-sdk-javascript-servicesjs-examples-is-there-more-....

Here's the direct link to the topic that explains how to create a basic oneshot search and display results.

0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...