Splunk® Enterprise

Module System User Manual

Acrobat logo Download manual as PDF


Splunk Enterprise version 7.3 is no longer supported as of October 22, 2021. See the Splunk Software Support Policy for details. For information about upgrading to a supported version, see How to upgrade Splunk Enterprise.
This documentation does not apply to the most recent version of Splunk® Enterprise. For documentation on the most recent version, go to the latest release.
Acrobat logo Download topic as PDF

Testing your app

Important notice: As part of Advanced XML deprecation, the Module System is officially deprecated beginning with Splunk Enterprise 6.3. For more information, see Advanced XML Deprecation.

Packaging and Installing

While creating your app, you'll want to test it.

You can either follow along by viewing the code in the /Dev_tutorial directory, or create a new directory parallel and populate it with the Source code for a more hands-on experience.

Typically, you would download an app from Splunk Apps using the Manage apps option of the App menu or create a local .spl file, where the app would be installed in the $SPLUNK_HOME/etc/apps directory. For demonstration purposes and initial debugging before your app is available on Splunk Apps, it is easier to manually install the app, as described in this section.

Your example app should have the following directory structure, located in the $SPLUNK_HOME/etc/apps/<yourApp> directory:

DirStruct00.png

  1. In $SPLUNK_HOME/etc/apps create a parallel directory to the Dev_tutorial directory, giving it the name of your app.
  2. For your new app, create the directories shown in the figure, above.
  3. Populate the directories with the example Source code files. Your app is now ready to run.
  4. Restart Splunk: ./splunk restart

Note: You can also compress your app in a tarball file with a .spl extension and use the App Manager to install your app.

Running the app

Run the Dev_tutorial app the same way you would run any other Splunk app:

  1. Start splunkWeb and, if needed, login.
  2. Click the App drop-down menu and select the Module System Tutorial app.
  3. Click the Examples drop-down menu in the upper-left and select the example you want to run. For Getting started, select Example: Using a Custom Module

Note: Make sure your app status is enabled.

Debugging

Debugging on your local machine, you can conveniently change your app code, in $SPLUNK_HOME/etc/apps/Dev_tutorial, and rerun your app.

The way you restart your app depends on what code you changed. If you changed only client-side code, it is sufficient to upgrade the version number, using _bump, and re-run your app:

http://localhost:8000/en-US/_bump

Note: Make sure you clear the browser cache before re-running your app.

If you made changes to your XML files and need to reload configuration data, use debug/refresh in addition to _bump to refresh all EAI handlers that support reload:

http://localhost:8000/en-US/debug/refresh

If you changed server-side code, you need to restart Splunk and SplunkWeb:

  1. On the command line, type splunk restart.
  2. Login to SplunkWeb.
  3. Start Module System Tutorial from the App menu.

Tip: You can specify global settings in your web.conf file, in the /default directory, that can be helpful for testing and debugging. For example, setting the JavaScript and CSS minify options. (See Admin Manual > web.conf )

Debugging JavaScript

You can use your favorite browser JavaScript debugger plugin, such as Firebug.

You'll notice that your JavaScript code is minified so you might want to expand it.

Note: Use console.debug("Your debug message"); to log messages to your debugger console.

Debugging Python

On the server, you can use the built-in Python logging facilities for debugging.

import logging

logger = logging.getLogger('splunk.module.CustomResultsTable')

You can enable debug logging, as described in Enable debug logging, and use the debug logging level:

logger.debug('your debug message')

For simple printf-style debugging, you'll find it easier to use the info logging level:

logger.info('your informative message')

Informative messages are logged in the $SPLUNK_HOME/var/log/splunk/web_service.log file.

You'll find most error messages, including Python execution errors, in the log file:

$SPLUNK_HOME/var/log/splunk/web_service.log

Last modified on 12 August, 2019
PREVIOUS
Anatomy of an app
  NEXT
Checklist

This documentation applies to the following versions of Splunk® Enterprise: 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.0.4, 7.0.5, 7.0.6, 7.0.7, 7.0.8, 7.0.9, 7.0.10, 7.0.11, 7.0.13, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.1.6, 7.1.7, 7.1.8, 7.1.9, 7.1.10, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.2.10, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.3.9


Was this documentation topic helpful?


You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters