Splunk® Enterprise

Splunk Dashboard Studio

Splunk Enterprise version 9.0 will no longer be supported as of June 14, 2024. 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.

Create a dashboard using REST API endpoints

Create or replicate dashboards from different environments using the data/ui/views REST API endpoint. For example, you can move a dashboard from a testing environment to production with the REST API endpoint. The REST API endpoints can also read, update, and delete dashboards.

Format the dashboard definition

When creating a dashboard using REST API endpoints, the components of a dashboard definition must follow a specific format.

Root node
The root node must be <dashboard version="2">, which indicates the dashboard is a Studio dashboard. You can also specify the theme as "light" or "dark" with the theme attribute in the root node. The following is an example of a root node.

<dashboard version="2" theme="dark">

Hidden elements
Hide different UI elements in View mode with hiddenElements. hiddenElements is an attribute of the root node.

  • Set hideEdit to "true" to hide the Edit button.
  • Set hideOpenInSearch to "true" to remove the ability to open and edit a query in the full Search experience.
  • Set hideExport to "true" to remove the ability to export dashboards.

The following is a hidden element example.

<dashboard version="2" theme="light" hiddenElements="{&quot;hideEdit&quot;:false,&quot;hideOpenInSearch&quot;:false,&quot;hideExport&quot;:false}">

Label
Title your dashboard with the label. The following is an example of a label.

<label>Sample Dashboard</label>

Description
Provide extra context about your dashboard with the description. The following is an example of a description.

<description>Sample Description</description>

Definition
The dashboard's JSON definition must be wrapped in <![CDATA[ … ]]>. If you save the dashboard with the UI instead of the API, any indenting or formatting in the JSON will be stripped. The following is an example of how a <![CDATA[ … ]]> wraps around a dashboard JSON definition.

 <definition><![CDATA[
  {
    <JSON definition here>
  }
 ]]></definition>

Create a dashboard

You can create a dashboard with the following steps.

  1. Write your initial REST command. The command uses the following structure: https://<host>:<mPort>/servicesNS/{user}/{app_name}/data/ui/views. For example, your REST command might look like the following:
    curl -k -u admin:pass https://localhost:8089/servicesNS/admin/search/data/ui/views \
    
  2. Write your header request parameter. For example, your header request parameter might look like the following:
    --header 'Content-Type: application/x-www-form-urlencoded' \
    
  3. Write the name data request parameter with the ID of your dashboard. For example, your request parameter might look like the following:
    --data-urlencode 'name=sample_dashboard' \
    
  4. Write the eai:data data request parameter. For example, your request parameter might look like the following:
    --data-urlencode 'eai:data=
    <dashboard version="2" theme="dark">
    

Example of creating a dashboard using REST API endpoints

The following example shows how to create a dashboard using the /data/ui/views endpoint.

curl -k -u admin:pass https://localhost:8089/servicesNS/admin/search/data/ui/views \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'name=sample_dashboard' \
--data-urlencode 'eai:data=
       <dashboard version="2" theme="light" hiddenElements="{&quot;hideEdit&quot;:false,&quot;hideOpenInSearch&quot;:false,&quot;hideExport&quot;:false}">
           <label>Sample Dashboard</label>
           <description></description>
           <definition><![CDATA[{"visualizations":{},"dataSources":{},"defaults":{"dataSources":{"ds.search":{"options":{"queryParameters":{"latest":"$global_time.latest$","earliest":"$global_time.earliest$"}}}}},"inputs":{"input_global_trp":{"type":"input.timerange","options":{"token":"global_time","defaultValue":"-24h@h,now"},"title":"Global Time Range"}},"layout":{"type":"absolute","options":{"display":"auto-scale"},"structure":[],"globalInputs":["input_global_trp"]},"description":"","title":"Sample Dashboard"}]]></definition>
       </dashboard>'

Reading, updating, and deleting a dashboard

You can pull, update, and delete your dashboard using GET, POST, and DELETE HTTP methods. For more details, see data/ui/views/{name} in the REST API Reference manual.

Last modified on 13 April, 2023
Download a dashboard   Visualization configuration options

This documentation applies to the following versions of Splunk® Enterprise: 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 9.0.5, 9.0.6, 9.0.7, 9.0.8, 9.0.9, 9.0.10


Was this topic useful?







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