We are using Splunk cloud in our enterprise and as part of an automation project we want programatic way for doing Splunk search. Based on Splunk website we found that there is node module splunk-sdk (https://www.npmjs.com/package/splunk-sdk) using which we can access Splunk even though the module is not mentioning explicitly anything about Splunk cloud. Following is the code we attempted but its failing to connect. Would like to know if any special configuration needs to be done in order to achieve the connection. (async=>{
let splunkjs = require('splunk-sdk');
let service = new splunkjs.Service({username: "myusername", password: "***"});
async function myFunction() {
try {
await service.login();
console.log("Login was successful: " + success);
let jobs = await jobs.fetch();
let jobList = jobs.list();
for(let i = 0; i < jobList.length; i++) {
console.log("Job " + i + ": " + jobList[i].sid);
}
} catch(err) {
console.log(err);
} Following is the error we are getting. Please help in understanding and resolving this issue if anyone has encountered the same issue.
... View more