Nougat Predominant Middleware
Join us to discuss the challenges, solutions and best practices for in-house JavaScript code sharing. Tuesday, 12/17 at 10am PT/1pm ET.Sign up here »

splunkdev-cli

0.1.9 • Public • Published

The Splunk Dev Command Line Interface (CLI)

When developing Splunk apps, you can use the Splunk Dev command-line interface (CLI) to make it easier to create and manage apps. The Splunk Dev CLI uses Yeoman for templates and Grunt for watch tasks.

Prerequisites

The Node Package Manager (NPM) is used to configure and set up the Splunk Dev CLI, so Node.js must be installed first. To download the latest version of Node.js (we recommend version 0.10.x or later), go to the Node.js website.

Install the Splunk Dev CLI

To install the Splunk Dev CLI (along with dependencies such as Yeoman), open a command prompt and enter the following command:

npm install -g splunkdev-cli

Now you'll have access to the Splunk Dev CLI globally, from anywhere on your system.

Using the Splunk Dev CLI

Use the splunkdev command to access the Splunk Dev CLI.

Usage

To use the Splunk Dev CLI, open a command prompt and use the splunkdev command as follows, where optional items are in square brackets:

splunkdev options

splunkdev command [command options] [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-V
--version
Displays the version number.
-H path
--splunkHome path
Specifies a $SPLUNK_HOME directory to use with a CLI command.
-v
--verbose
Specifies verbose output for a CLI command.

Commands

The following table lists the splunkdev commands.

CommandDescription
appsList and manage Splunk apps.
configConfigure the CLI login credentials for the current Splunk instance.
createCreate a Splunk app.
reloadReload resources and configurations for all apps, without restarting Splunk.
settingsSpecify whether to use minified files in Splunk.
serviceStart, stop, and restart Splunk services.
watchWatch for configuration changes to a specific app or to Splunk.

Examples

To get help for the splunkdev command:

splunkdev –h

splunkdev –-help

To get help for the splunkdev commands apps and watch:

splunkdev apps –h

splunkdev watch –-help

splunkdev apps

Use the splunkdev apps command to list and manage your Splunk apps. If you don't specify any options, all non-system, enabled apps are listed.

Usage

splunkdev apps [appname] [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-s
--system
Lists Splunk apps, including system apps.
-d
--disabled
Lists Splunk apps, including disabled apps.
-s {enabled | disabled}
--state {enabled | disabled}
Changes the app state.
-R
--remove
Removes the specified app from Splunk.

Examples

List installed apps:

splunkdev apps

List all apps, including disabled and system apps:

splunkdev apps --disabled –-system

List all the apps that start with "test":

splunkdev apps test*

Remove the app called "my_app":

splunkdev apps my_app –-remove

Remove all apps with names that start with "test":

splunkdev apps "test*" –-remove

Change the state of the "my_app" app to disabled:

splunkdev apps my_app --state disabled

Change the state of the "my_app" app to enabled:

splunkdev apps my_app --state enabled

splunkdev config

Use the splunkdev config command to configure the CLI login credentials for the current Splunk instance. These credentials are used by splunkdev commands that communicate with splunkd, such as watch, reload, and settings.

Usage

splunkdev config [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-R
--remove
Removes the CLI login credentials configuration for the current Splunk instance.

Examples

Set the CLI login credentials:

splunkdev config

splunkdev create

Use the splunkdev create command to create a Splunk app. You'll be asked whether to restart Splunk afterwards.

Usage

splunkdev create appname

splunkdev create [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-d
--dependencies
Install dev comand line tool dependencies for local use of grunt. This can also be done later by running npm install in the new app directory

Examples

Create an app called "my_app" without installing node dependencies locally:

splunkdev create my_app

Create an app called "my_app2" and install local node-based tools:

splunkdev create my_app2 -d

splunkdev reload

Use the splunkdev reload command to reload resources and configurations for all apps, without restarting Splunk.

Usage

splunkdev reload [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.

splunkdev settings

Use the splunkdev settings command to specify whether to use minified files in Splunk.

Usage

splunkdev settings [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-m {true | false}
--minified {true | false}
Indicates whether to use minified CSS and JS files.

Examples

Use unminified CSS and JS files in the web environment:

splunkdev settings -m false

splunkdev service

Use the splunkdev service command to start, stop, and restart Splunk services. If a particular service is not specified, the action is performed on all services.

Usage

splunkdev service {start | stop | restart} [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-s {splunkd | splunkweb | * }
--service {splunkd | splunkweb | * }
Indicates the Splunk service to start, stop, or restart:
splunkd: Splunk server daemon
splunkweb: Splunk Web interface
*: both services

Examples

Start all Splunk services:

splunkdev service start

Restart all Splunk services:

splunkdev service restart

Stop all Splunk services:

splunkdev service stop

Start the splunkd service:

splunkdev service stop -s splunkd

Restart the splunkweb service:

splunkdev service restart --service splunkweb

splunkdev watch

Use the splunkdev watch command to watch for changes to a specific app or to Splunk. When a change occurs that requires restarting a Splunk service or reloading a configuration file, that action is performed automatically. For example, changes to app configuration or Python files require the app resources to be reloaded, and changes to the app's navigation file require splunkweb to be restarted.

To stop the current watch task, press Ctrl+C.

Usage

splunkdev watch [options]

Options

The following table lists the possible command-line options.

OptionDescripton
-h
--help
Displays help.
-a appname
--app appname
Watches for changes to the specified app.
-s
--splunk
Watches for changes to all apps and Splunk global files.

Examples

Watch for changes to the "my_app" app:

splunkdev watch --app my_app

Install

npm i splunkdev-cli

DownloadsWeekly Downloads

11

Version

0.1.9

License

none

Last publish

Collaborators

  • avatar