Splunk Modules, Add-ons, and Apps are designed to be distributed to other Splunk instances in as simple and platform-agnostic a way as possible.
Reading this How-To can help you to correctly package your app or add-on.
'Splunk App Components' shows the technologies and component parts that make up an app or add-on, including the required directory structure.
In general, modules should not be distributed as stand-alone packages. Modules should be encapsulated in apps or add-ons to facilitate distribution using Splunkbase.
That said, it is helpful to understand exactly how to package a module for distribution. For more information on modules, review 'what is a module?'.
This describes the module/ directory structure. In general, including files in a module that are not specified here is not recommended.
/<app_or_add-on_name>/appserver/modules/<module_name>
/<app_or_add-on_name>/appserver/modules/<module_name>/<module_name>.conf
/<app_or_add-on_name>/appserver/modules/<module_name>/<module_name>.css
/<app_or_add-on_name>/appserver/modules/<module_name>/<module_name>.html
/<app_or_add-on_name>/appserver/modules/<module_name>/<module_name>.js
/<app_or_add-on_name>/appserver/modules/<module_name>/<module_name>.py
The module configuration file format is defined as follows:
[module]
className=Splunk.Module.<module_name> (REQUIRED)
superClass=<module that was super classed> (OPTIONAL)
description=<some descriptive text> (OPTIONAL)
[param:<param_name>]
required = {Boolean} If True, param must be specified for module in view XML (REQUIRED)
default = {String} The default value for this param (OPTIONAL)
label = {String} Some descriptive text about the param (OPTIONAL)
values = {String} Comma separated list of allowed values for the param (OPTIONAL)
Example module configuration file:
[module] className = Splunk.Module.HiddenSearchSwapper superClass = Splunk.Module description = Given the time range selected by time range picker, adjusts the context's search [param:rangeMap] required = True label = Use this to specify a list of searches and time ranges associated with them ### EXAMPLE CONFIG # # <module name="HiddenSearchSwapper"> # <param name="rangeMap"> # <param name="default"> # <param name="search">index=main fiz=baz</param> # </param> # <param name="rt"> # <param name="search">index=main foo=bar</param> # </param> # <param name="1d"> # <param name="search">index=summary marker=search1</param> # </param> # <param name="1w"> # <param name="savedsearch">my cool saved search that actually exists</param> # </param> # <param name="1m"> # <param name="search">index=summary marker=search3</param> # </param> # </param> # </module>
Packaging apps and add-ons should be a straightforward experience. For more information about add-ons, review 'what is an addon?' and 'what is an app?'. Additionally, consider reading through the core Splunk app and add-on packaging information documentation.
NB: Apps and add-ons must NEVER be packaged inside other apps and add-ons. Apps can have dependencies on add-ons, but never to the extent that they are packaged inside another app or add-on.
To handle dependencies, use one of the following methods :
In general, it is recommended that you do not include custom directories or files.
One exception is to use an <app_or_add-on_name>.conf custom configuration file. By following this convention, inter-app configuration namespace collisions are easier to avoid.
The app or add-on directory structure is defined as follows:
/<app_or_add-on_name>
/<app_or_add-on_name>/appserver
/<app_or_add-on_name>/appserver/controllers
/<app_or_add-on_name>/appserver/modules
/<app_or_add-on_name>/appserver/static
/<app_or_add-on_name>/appserver/templates
/<app_or_add-on_name>/bin
/<app_or_add-on_name>/default
/<app_or_add-on_name>/default/data/ui/nav
/<app_or_add-on_name>/default/data/ui/views
/<app_or_add-on_name>/lookups
/<app_or_add-on_name>/metadata
All apps and add-ons must include /default/app.conf. Moreover, there are a number of required and optional values within app.conf to consider.
The core Splunk documentation for app.conf provides the defacto reference document for required and optional stanzas, keys, and values.
If using SplunkBase as the primary repository for apps, the following app.conf requirements must be met for each app iteration:
For example, the first iteration of an app might have the following in default/app.conf:
[ui]
is_visible = 1
label = my_app
[install]
author=araitz
description=This is a cool app
build = 1
[launcher]
version = 1.0
Subsequent iterations of this app that are uploaded to Splunkbase must have an incremented "build" number greater than 1 as well as a different version number (e.g 1.0.1, 1.1, 2.0, etc).
On that note, it is a good practice to decide on a version standard prior to the initial release of an app. In most cases, a major-minor system will suffice:
It cannot be emphasized enough how important the "id" of an app is, and subsequently how important it is to pick the right "id" initially. In the world of Splunk and Splunkbase, changing an app's "id" is tantamount to creating an entirely new app, and comes with several unpleasant headaches when trying to inform or migrate users of the previous app "id". Changing an "id" is thus not recommended.
Finally, keep in mind that any changes made to an app's default configuration file values will not be effective if the values are present in the app's local configuration files.
For example, the following setting exists in default/inputs.conf:
[monitor:///my_app/my_file]
sourcetype=my_special_sourcetype
During the course of normal operations, a Splunk administrator sets the following in local/inputs.conf:
[monitor:///my_app/my_file]
sourcetype=my_special_sourcetype
host=special_host
If the sourcetype definition in default/inputs.conf changes in a subsequent iteration of the app, the change will not be respected due to Splunk's order of precedence.
To upload your app or add-on to Splunkbase, a few more steps are needed to create a complete package that passes the upload validation process to be fully ready for distribution.
Apps and add-ons can be packaged with a screenshot and an icon. Although not strictly required, including a screenshot and an icon are highly recommended.
The screenshot gives Splunkbase users a preview of the app or add-on's look and feel before they download. During the upload process, Splunkbase will extract the screenshot file from the app and use it on the app or add-on's download page.
To include a screenshot, place a 623px x 350px PNG image in the following location:
/<app_or_add-on_name>/appserver/static/screenshot.png
Upon upload, Splunkbase will attempt to re-size the provided image if it does not precisely match the above dimensions. For best results, make sure the image size is in the 98:55 ratio and do not include browser chrome in your image.
The app icon can be used to represent a particular author, technology, or brand. The icon will appear in Splunk's built-in launcher app next to the app or add-on name and description as well as next to the app or add-on name on Splunkbase.
To include an icon, place a 35 x 35 PNG image in the following location:
/<app_or_add-on_name>/appserver/static/appicon.png
The app icon for Web Intelligence as viewed from the launcher app:
Splunkbase requires that all submitted packages are compressed tarballs with the file suffix '.spl'.
See 'package your app or add on' in the core Splunk documentation for additional details.
At this point, your app or add-on should be good to go! Upload your app to Splunkbase, have a beer, and bask in your own glory.