Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 36 ยท Reports, Dashboards and Alerts

Splunk Dashboards: Classic Simple XML and Dashboard Studio

Build Splunk dashboards: panels and visualizations, Simple XML structure, Dashboard Studio, base searches with post-process searches, refresh settings and layout tips.

A dashboard puts several searches on one page, each as a panel with a visualization. Splunk has two dashboard systems: Classic dashboards, defined in an XML dialect called Simple XML, and Dashboard Studio, a newer editor that stores a JSON definition and gives pixel-level layout. This lesson shows how both are built and how to keep dashboards fast.

Creating a dashboard

In Search & Reporting choose Dashboards > Create New Dashboard, give it a title, choose the permissions (Private or Shared in App), and choose Classic Dashboards or Dashboard Studio (with a grid or absolute layout). You can also run a search and use Save As > Dashboard Panel, which adds the search as a panel to a new or existing dashboard.

A panel contains a search (or a saved report reference) and a visualization: single value, line, area, column, bar, pie, scatter, bubble, table, map (cluster map, choropleth), gauge (radial, filler, marker), event listing and more. Choose the visualization by the question:

Question Visualization
How many right now? Single value (with trend sparkline)
How does it change over time? Line or area over timechart
Which categories are biggest? Bar or column over stats ... by
Where does it happen? Choropleth or cluster map with iplocation / geostats
What exact rows? Table

Classic dashboards: Simple XML

A classic dashboard is a tree of <dashboard>, <row>, <panel> and visualization elements:

XML
<dashboard version="1.1" refresh="300">
  <label>Web Health</label>
  <description>Requests and errors, refreshed every 5 minutes</description>
  <row>
    <panel>
      <title>Requests per hour</title>
      <chart>
        <search>
          <query>index=web sourcetype=access_combined | timechart span=1h count</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.chart">line</option>
      </chart>
    </panel>
    <panel>
      <title>Error rate</title>
      <single>
        <search>
          <query>index=web | stats count(eval(status>=500)) as errors count as total | eval rate=round(errors/total*100,2)</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="unit">%</option>
      </single>
    </panel>
  </row>
</dashboard>

Key rules: a dashboard holds rows; a row holds panels laid out side by side; a panel holds one or more elements (<chart>, <table>, <single>, <map>, <viz>, <html>). Open Edit > Source to edit the XML directly. Characters such as < and > inside a query must be escaped (&lt;, &gt;) or the search wrapped in <![CDATA[ ... ]]>; this is the most common reason an XML dashboard refuses to save.

Try it: generate Simple XML from a spec (stand-in)

Administrators often generate dashboards from a list. This stand-in builds valid, escaped Simple XML from a Python description.

Python Stand-in: build a Simple XML dashboard

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that status>=500 comes out as status&gt;=500: that is the escaping Splunk needs.

Base searches and post-process searches

Ten panels that each run their own search over the same events are slow and expensive. Instead, define one base search with an id and let each panel run a light post-process search on its results:

XML
<search id="base">
  <query>index=web sourcetype=access_combined | fields status, uri, clientip | bin _time span=1h</query>
  <earliest>-24h@h</earliest>
  <latest>now</latest>
</search>

<chart>
  <search base="base">
    <query>stats count by status</query>
  </search>
</chart>

The base search runs once; each post-process search runs on its result set in the browser session of the job. Rules that matter: the base search should end with a transforming command (stats, chart) or an explicit fields list, because post-processing works on a limited result set (events are capped at 500,000 and results beyond that are dropped); keep the base search's output small; and every field the panels need must still be present after the base search. In Dashboard Studio the same idea is called a chained search (extend a data source).

Try it: why base searches save work (stand-in)

Python Stand-in: base search versus one search per panel

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Dashboard Studio

Dashboard Studio stores a JSON definition with four parts: dataSources (searches), visualizations, inputs and layout. You drag visualizations onto a canvas (absolute layout lets you place them freely, even over a background image; grid layout snaps), pick a data source from the Data panel, and style options in the right-hand panel. Data sources are ds.search (a search), ds.savedSearch (a report), ds.chain (a post-process search) and ds.test (static sample rows, handy while designing).

Studio has richer visuals (single values with sparklines, choropleth maps, markdown and rectangle shapes, connecting lines) and drilldowns that set tokens. Not every classic feature exists: custom JavaScript and CSS are limited, so very customized classic dashboards are not always convertible. Splunk provides a Convert action from Classic to Studio for compatible dashboards.

Refresh, performance and layout tips

  • Auto-refresh: refresh="300" on <dashboard> or per search (<refresh>5m</refresh>). Avoid real-time panels on shared dashboards; a 1-minute refresh over 15 minutes is almost as good and far cheaper.
  • Use scheduled reports for panels that need heavy searches, and reference them (<search ref="Report name"/>); the dashboard then shows the last results instantly.
  • Prefer tstats over data models or accelerated data for large time ranges.
  • Put the most important single values at the top left, group related panels on one row, and give each panel a title that states what it shows.
  • Add a time input and a few filters, described in inputs, tokens and drilldowns, and keep the count small.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the main benefit of a base search with post-process searches?

    One base search feeds many panels, so the index is scanned once instead of once per panel.
  2. 2. Why must status>=500 be escaped inside Simple XML <query>?

    The dashboard is XML, so angle brackets must be written as &lt; and &gt; or placed in a CDATA section.
  3. 3. Which Dashboard Studio data source type runs a post-process (chained) search?

    ds.chain extends another data source and applies extra SPL to its results.
  4. 4. Which visualization best answers 'Where do events happen?'

    Maps show geography, usually with iplocation and geostats or a lookup of regions.

Summary

  • Dashboards hold panels; each panel has a search and a visualization.
  • Classic dashboards use Simple XML (rows, panels, elements); Studio uses JSON with data sources, visualizations, inputs and layout.
  • Use a base search plus post-process searches to avoid repeated scans.
  • Reference scheduled reports and limit real-time panels to keep dashboards quick.

Next: Inputs, tokens and drilldowns