How to use the splunk-sdk.Service function in splunk-sdk

To help you get started, we’ve selected a few splunk-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aol / moloch / wiseService / source.splunk.js View on Github external
["host", "username", "password", "query", "keyColumn"].forEach((item) => {
    if (this[item] === undefined) {
      console.log(this.section, `- ERROR not loading since no ${item} specified in config file`);
      return;
    }
  });

  if (this.periodic) {
    this.cacheTimeout = -1; // Don't cache
    this[this.api.funcName(this.type)] = this.sendResultPeriodic;
    setInterval(this.periodicRefresh.bind(this), 1000 * this.periodic);
  } else {
    this[this.api.funcName(this.type)] = this.sendResult;
  }

  this.service = new splunkjs.Service({username: this.username, password: this.password, host: this.host, port: this.port, version: this.version});

  this.service.login((err, success) => {
    if (err) {
      console.log("ERROR - Couldn't login to splunk - ", err);
      return;
    }
    if (this.periodic) {
      this.periodicRefresh();
    }
    
    console.log("Login was successful: " + success);
  });

  api.addSource(section, this);

  this.sourceFields = [this.esResultField];
github microsoft / AzureMonitorAddonForSplunk / bin / app / azure_monitor_logs.js View on Github external
exports.getOrStoreSecrets = function (name, singleInput, done) {

    // make a copy of singleInput
    var mySingleInput = JSON.parse(JSON.stringify(singleInput));

    var inputDefinition = ModularInput._inputDefinition;
    var session_key = inputDefinition.metadata.session_key;
    var service = new splunkjs.Service({ sessionKey: session_key });
    var storagePasswords = service.storagePasswords({ 'app': 'TA-Azure_Monitor' });

    var propsAppId = {};
    var propsAppKey = {};
    if (~name.indexOf('azure_activity_log:')) {
        propsAppId.name = 'AzureMonitorActivityLogAppID';
        propsAppKey.name = 'AzureMonitorActivityLogAppKey';
    } else {
        propsAppId.name = 'AzureMonitorDiagnosticLogsAppID';
        propsAppKey.name = 'AzureMonitorDiagnosticLogsAppKey';
    }
    propsAppId.password = singleInput.SPNApplicationId;
    propsAppKey.password = singleInput.SPNApplicationKey;

    if (_.isUndefined(singleInput.SPNApplicationId) && _.isUndefined(singleInput.SPNApplicationKey)) {
        done(null, singleInput);
github splunk / splunkrepl / splunkrepl.js View on Github external
}

    var parsed = url.parse(host);

    if (parsed.protocol == null) {
        parsed.protocol = nconf.get('scheme') + ':';

    }

    if (parsed.port == null) {
        parsed.port = nconf.get('port');
    }
    
    var scheme = parsed.protocol.substring(0, parsed.protocol.length - 1);
    
    var service = new splunk.Service({
        host:parsed.hostname,
        scheme:scheme,
        username:user,
        password:pwd,
        port:parsed.port
    }); 

    return service;
}
github octoblu / meshblu / lib / splunk.js View on Github external
var config = require('./../config');

if(config.splunk && config.splunk.indexObj){
  var splunk = require('splunk-sdk');
  var splunkService = new splunk.Service({
    host: config.splunk.host,
    port: config.splunk.port,
    scheme: config.splunk.protocol,
    username: config.splunk.user,
    password: config.splunk.password
  });
  var myindexes = splunkService.indexes();
  myindexes.fetch(function(err, myindexes) {
    if(myindexes){
  	 config.splunk.indexObj = myindexes.item(config.splunk.index);
    }
  });

  module.exports = splunkService;
}

splunk-sdk

SDK for usage with the Splunk REST API

Apache-2.0
Latest version published 2 years ago

Package Health Score

47 / 100
Full package analysis