splunkdev-grunt
v0.1.9
Published
Grunt tasks for building Splunk applications.
Downloads
20
Maintainers
Readme
splunkdev-grunt
Grunt tasks for building Splunk applications.
Getting Started
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install splunkdev-grunt --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('splunkdev-grunt');
List of tasks
Grunt "splunk-services" task
This task allow you to manipulate Splunk services.
Requirements
This task expects configuration:
grunt.config.init({
splunk: {
splunkHome: '/path/to/Splunk/home/folder',
splunkd: {
username: 'admin',
password: 'splunkd_password',
scheme: 'https',
host: 'localhost',
port: '8089',
version: '6.0'
}
}
});
If you have splunk-cli installed - you can run splunk-cli config
to save configuration for specific Splunk instance and load it with next code snipped:
grunt.config.init({
splunk: require('splunkdev-grunt/lib/configuration').get()
});
Available task options
splunk-services:reload-apps
- reload application configurationssplunk-services:*:start
- start all Splunk servicessplunk-services:*:stop
- stop all Splunk servicessplunk-services:*:restart
- restart all Splunk servicessplunk-services:splunkweb:start
- start splunkweb servicesplunk-services:splunkweb:stop
- stop splunkweb servicesplunk-services:splunkweb:restart
- restart splunkweb servicesplunk-services:splunkd:start
- start splunkd servicesplunk-services:splunkd:stop
- stop splunkd servicesplunk-services:splunkd:restart
- restart splunkd service
Grunt "splunk-watch" task
Task watches for changes under Splunk home folder and do required steps, like call livereload or reload Splunk app configurations or restart required Splunk services.
Requirements
This task depends on "splunk-contrib-watch" task.
Available task options
splunk-watch:apps:*
- watch for all Splunk applicationssplunk-watch:apps:[appname]
- watch for specific application [appname]splunk-watch:splunk
- watch for changes in Splunk (core components)splunk-watch:*
- watch for all applications and core components
Notes
Implementation of task "splunk-watch" configure and launch grunt task "grunt-contrib-watch". If you need to use "grunt-contrib-watch" at the same time as you use "splunk-watch" - you will need to use lib/watchConfig
module and just launch "watch" task from "grunt-contrib-watch". For example:
var splunkWatchConfig = require('splunkdev-grunt/lib/watchConfig');
var watchConfig = { /* ... your watch configuration ... */ };
// If you need to watch for application changes
splunkWatchConfig.watchForApp(watchConfig, 'application_name');
// If you need to watch for core Splunk components
splunkWatchConfig.watchForSplunk(watchConfig);
// Configure grunt
grunt.config.init({
watch: watchConfig
});
// Use watch task by default
grunt.registerTask('default', ['watch']);
Grunt "splunk-pack" task
Pack application into tar.gz archive for uploading to the store
Usage
grunt.config.init({
splunk: {
pack: {
sourceDir: __dirname,
output: path.join(__dirname, 'myapp.tar.gz'),
source: [
'**/*',
'!*.tar.gz'
]
}
}
});
Other useful hidden API
Module "splunkdev-grunt/lib/environment"
Function "splunkHome"
Helps to discover current Splunk home directory. It checks first for SPLUNK_HOME
environment variable, after that checks if current working directory is subfolder of Splunk folder.
var splunkHome = require('splunkdev-grunt/lib/environment').splunkHome();
Module "splunkdev-grunt/lib/apps"
Function "getCurrentApp"
Gets current application if current working directory is under one of the applications in Splunk apps directory.
var currentApp = require('splunkdev-grunt/lib/apps').getCurrentApp();
if (!currentApp) {
var applicationName = currentApp.name();
var pathToApplication = currentApp.path();
}
Release History
(Nothing yet)