Package your SPL2-based application
Before packaging an SPL2-based application, you must first download your modules into the /apps/<app_name>
folder, cleanup the files in the /apps/<app_name>
folder, and add your README file. You can then package the application.
Download the app modules
You must download the app modules from the data orchestrator to your /apps/<app_name>
folder.
In the Splunk CLI, navigate to the
$SPLUNK_HOME
folder.Use the
download-spl2-modules
command to download the modules. The following example shows the command to specify:./bin/splunk download-spl2-modules app <app-name> -dest default
You are prompted to confirm that the action will overwrite the any files in the destination folder and that the action can't be undone. Type
y
to confirm the download.If you receive an error like
An authentication error occurred: Client is not authenticated
, add the authentication to thedownload-spl2-modules
command. For example:./bin/splunk download-spl2-modules app <app-name> -dest default -auth <userid>:<password>
Under the /default/data/
folder, a new folder called spl2
, is created. The modules are added to that folder.
The following image shows the folder structure for an app that consists of 3 modules: setup, _default, and functions.
Confirm the module dowload
You can confirm that the modules were downloaded by navigating to the $SPLUNK_HOME/etc/apps/<appname>/default/data/spl2/
folder. Use a text editor to open the module files and confirm their contents.
Remove unnecessary folders or files
Before you proceed with packaging your app, you can remove any unnecessary folders or files from the app. For example:
- If your app doesn't contain any scripts, you can remove the
bin
folder from the app. - Under
/default/data/ui/views
a blank README file is added by default when you create a blank app. This is the folder where dashboard information is stored. If you don't need that README file, you can remove it.
Move the local folder contents to the default folder
As part of creating your SPL2-based app, some items might have been created in the apps/<app_name>/local
folder. Except for the app.conf
file, these items must be moved to the apps/<app_name>/default
folder before you package the app.
After the app is installed, Splunk Admins can create a local
folder if they decide to customize your app.
Before you package the app, you must:
- If necessary, manually move the contents from the
local
folder to thedefault
folder. Do not move theapp.conf
file. - Delete the
local
folder in your app.
Add your app-level README to the app
In the root folder of your app, place the README file for that app.
For more information about the instructions and guidance you should include in the app-level README file, see Prepare SPL2-based apps for packaging.
Package your app
Packaging the app enables you to deploy your Splunk app to other Splunk deployments or to Splunkbase.
As part of packaging the app, you must merge the
local.meta
file contents into thedefault.meta
file.
The CLI command to package an app and merge the local.meta
file contents is:
./bin/splunk package app <app_name> -merge-local-meta t
Where the package is stored
This command creates a tar archive of the /app
folder and saves the package with the .spl
file extension to the $SPLUNK_HOME/share/splunk/app_packages
folder.
- Dashoard information is stored in an XML file located in the
/default/data/ui/views
folder. - Information about saved searches, or reports, are stored in the
savedsearches.conf
file located in the/data
folder. - Information about lookups is stored in the
transforms.conf
file located in the/data
folder.
More information about packaging apps
- To understand how Splunk app packages are deployed, see Release and maintain Splunk apps.
- To learn how deployment architecture affects a Splunk app, see Deployment architecture.
- To learn about the tools you can use to package your app, see Package apps.
Next step
After you package your app, you should test that the installation of your app occurs without errors. See Test the installation of your SPL2-based application.