Create custom visualizations for Dashboard Studio with the Splunk dashboard extension CLI

Use the CLI to scaffold, build, and package custom visualizations as Splunk apps, configure visualization behavior, and troubleshoot common project and packaging errors.

You can use @splunk/create --mode=dashboard-studio-extension to scaffold a custom visualization project and package it as a Splunk app (.spl file) that can be installed for use in Splunk Dashboard Studio. This process consists of the following steps:

  1. Create the custom visualization project.

  2. Build the custom visualization using build.

  3. Package the visualization as a Splunk app.

  4. (Optional) Add visualizations to the existing project.

Prerequisites

  • Node.js 22.0.0 or higher

  • One of the following:

    • npm 10 or higher

    • Yarn 1.22 or higher

Create the custom visualization project

You can create a custom visualization project using one of the following ways:

npm
CODE
npm create @splunk/create@latest --mode=dashboard-studio-extension
yarn
CODE
yarn create @splunk/create@latest --mode=dashboard-studio-extension
Configure the following project details:
Detail Description Default value
Project name Can only consist of letters, numbers, and underscores. It cannot include a slash or leading dot. There must also be no existing directory with the name. my_custom_viz
Visualization label Name displayed for the custom visualization in the Splunk UI Automatically suggested from the project name
Description Description for the custom visualization A custom visualization for Splunk Dashboard Studio
Author Author name n/a
Template choice JavaScript or React + JavaScript JavaScript
In non-interactive mode, pass project-name + --template to skip all prompts.

You can choose one of the following templates for your project. The templates include a working example of a custom table visualization.

Template Dependencies Entry point Key API Description
JavaScript (--template javascript)
  • @splunk/dashboard-extension

  • esbuild
  • chalk
  • tar
visualization.js (plain JavaScript, no framework) VisualizationAPI.addDataSourcesListener(({ dataSources, loading }) => { ... })
  • Minimal bundle size

  • Simple visualizations

  • No framework dependency

  • Integrating third-party libraries with React compatibility issues

React (--template react)
  • @splunk/dashboard-extension/react

  • react@18

  • react-dom

  • esbuild

  • chalk

  • tar

visualization.jsx (JSX) useDataSources() hook → { dataSources, loading }

Recommended for:

  • Recommended for most projects

  • Developers who prefer React component model and hooks

  • React hooks manage state, rerenders, and subscription life cycle via VisualizationExtensionProvider.

The following shows a typical project structure after scaffolding:
CODE
my_viz/ 
├── package.json                         # Node scripts & devDependencies 
├── README.md 
├── build.mjs                            # esbuild build script 
├── package.mjs                          # Packager script (runs packaging logic) 
├── build-plugins/ 
│   └── css-and-size.mjs                 # esbuild CSS injection + bundle size warnings 
├── package/ 
│   └── app/ 
│       └── app.conf                     # Splunk app identity (source of truth) 
└── visualizations/ 
     └── my_viz/                          # One visualization per subdirectory 
         ├── config.json                  # Viz metadata for Splunk 
         └── src/ 
             ├── visualization.js (or .jsx) 
             ├── visualization.css 
             └── assets/ 
                 └── ChartColumnSquare.svg
Running yarn build generates a dist/ directory:
CODE
dist/ 
└── my_viz/ 
     └── visualization.js   # Bundled output

Bundle the custom visualization using build

To bundle custom visualizations, refer to the following workflow:
CODE
cd my_viz 
yarn install       # Install dependencies 
 
yarn build         # One-time build → dist/ 
yarn dev           # Watch mode (rebuilds on file changes) 
yarn build:prod    # Production build (minified, no sourcemaps) 
 
yarn package       # Package into a .spl Splunk app
The build system uses esbuild to bundle each visualization's src/visualization.js (or .jsx). The build system automatically discovers all subdirectories of visualizations/. Each subdirectory is its own bundle entry point. The build system outputs dist/{vizName}/visualization.js per visualization. CSS is injected directly into the JS bundle, with no separate CSS file needed. Assets (SVG, images, fonts) are inlined as data URLs. Watch mode (yarn dev) creates persistent esbuild contexts for fast rebuilds.
Each visualization has its own config.json file, which tells Splunk how to display and use the visualization. The following shows an example config.json file:
JSON
{ 
   "config": { 
     "name": "My Visualization", 
     "description": "...", 
     "category": "Custom", 
     "icon": null, 
     "dataContract": { 
       "requiredDataSources": ["primary"], 
       "optionalDataSources": [] 
     }, 
     "size": { 
       "initialWidth": 400, 
       "initialHeight": 300 
     }, 
     "optionsSchema": {}, 
     "editorConfig": [] 
   }, 
   "showTitleAndDescription": true, 
   "includeInToolbar": true, 
   "includeInVizSwitcher": true, 
   "showDrilldown": false, 
   "canSetTokens": [], 
   "hasEventHandlers": false 
}
The following provides information for key fields in the config.json file:
Field Purpose

config.name

Display name in Splunk UI

config.category

Toolbar category grouping

config.dataContract.requiredDataSources

["primary"] means the viz requires a search result

config.size

Initial dimensions when dropped onto a dashboard

includeInToolbar

Whether it appears in the Dashboard Studio visualization list

includeInVizSwitcher

Whether it appears in the visualization type switcher

The app.conf file, located in package/app, is the source of truth for the Splunk app, not package.json. The following shows an example app.conf file:
PYTHON
[package] 
id = my_viz           # Splunk app ID 
 
[ui] 
is_visible = 1 
label = My Visualization 
 
[launcher] 
author = Your Name 
description = A custom viz 
version = 0.1.0 
 
[install] 
is_configured = 0 
build = <auto-populated from git hash> 
 
[manifest] 
category = Custom
The package id must consist only of lowercase letters, numbers, hyphens, and underscores. It cannot start with a hyphen or underscore, and must be between 1-100 characters.

Package the visualization as a Splunk app

You can use yarn package to package the visualization. yarn package does the following:

  1. Validate project structure. Checks for package.json, visualizations/ directory, config.json in each visualization directory and built dist/{vizName}/visualization.js files.

  2. Read package/app/app.conf for app identity (id, version, label, author, etc.).

  3. Create staging directory at stage/{appId}/ with the full Splunk app directory layout.

  4. Copy each built dist/{vizName}/visualization.js to appserver/static/visualizations/{vizName}/visualization.js. Copy source maps if present.

  5. Generate Splunk config files:

    • default/visualizations.conf: register each visualization with Splunk (label, description, framework_type = studio_visualization)

    • metadata/default.meta: set export permissions (export = system)

  6. Generate app.manifest (JSON manifest Splunk uses for app inspection).

  7. Create .spl archive in dist/{appId}-{version}-{7-char-git-hash}.spl.

The output of yarn package is as follows:

  • stage/{appId}/: staged app directory (useful for debugging app structure)

  • dist/{appId}-{version}-{hash}.spl: installable Splunk app file. A .spl file is a gzipped tar archive (.tar.gz with a different extension). The archive contains a single top-level directory named after the app ID, which contains the full Splunk app structure. You can install it via Install app from file in Splunk Enterprise.

Add visualizations to an existing project

The packager automatically discovers all subdirectories of visualizations/. To add more visualizations to an existing project, do the following:

  1. Create visualizations/my_new_viz/ with config.json and src/visualization.js.

  2. Run yarn build && yarn package to bundle all visualizations in the project into the same .spl file.

Troubleshoot

The following lists common errors you may encounter in this process:
Error Cause Fix

Missing package.json

Not in a project directory

cd into the project root.

Missing visualizations/ directory

Wrong directory

Run from project root.

No config.json found

Viz directory missing config

Add config.json to each viz directory.

Missing built visualization bundles

Not built yet

Run yarn build first.

Missing package/app/app.conf

Old project or wrong directory

Ensure package/app/app.conf exists.

Invalid [package] id

ID has unsupported characters, such as uppercase and spaces.

Use only lowercase letters, numbers, hyphens, and underscores.

Directory "X" already exists

Duplicate project name

Choose a different project name.