Developing Dashboards, Views, and Apps for Splunk Web

 


How to use switcher modules

This documentation does not apply to the most recent version of Splunk. Click here for the latest version.

How to use switcher modules

Switchers are useful for creating nav within your view, like tabs or pulldown menus that users can use to switch between content. Switchers create a fork between different branches of XML, but the choice doesn't influence any individual search in those child branches. This is similar to lister modules, but listers allow the user to insert input that affects the search(es) underneath.

The current Switcher modules that are most useful are 'PulldownSwitcher', 'TabSwitcher' and 'LinkSwitcher'. Here is an example of LinkSwitcher. There are more examples in the UI examples app, available on Splunkbase.

Add chrome

You must first add the chrome and nav for your page:

<view template="dashboard.html">
  <label>Switcher Intro</label>
  <module name="AccountBar" layoutPanel="appHeader"/>
  <module name="AppBar" layoutPanel="navigationHeader"/>
  <module name="Message" layoutPanel="messaging">
    <param name="filter">*</param>
    <param name="clearOnJobDispatch">False</param>
    <param name="maxSize">1</param>
  </module>
  <module name="TitleBar" layoutPanel="viewHeader">
    <param name="actionsMenuFilter">dashboard</param>
  </module>

The group attributes can be confusing cause sometimes they are pulled to populate the dashboard panel titles, as in the module immediately below. But in the immediate child modules of switcher modules, the group attributes become the relevant 'label' for the switcher element. ie the tab's or pulldown option's text.

LinkSwitcher

This is a basic example using a LinkSwitcher with four children. All children use chart patterns:

The last child adds a TimeRangePicker to drive the time of results.

<module name="LinkSwitcher" layoutPanel="panel_row2_col1">
  <param name="mode">independent</param>
  <param name="label"> </param>

first switcher child

Note that the group attribute set on HiddenSavedSearch governs what 'label' represents this branch in the switcher. For LinkSwitcher the label displays as a link.

<module name="HiddenSavedSearch" group="cpu time by processor" autoRun="True">
  <param name="savedSearch">Pipeline processors with most processor time</param>
    <module name="HiddenChartFormatter">
      <param name="chart">line</param>
      <param name="primaryAxisTitle.text">CPU seconds</param>
      <param name="secondaryAxisTitle.text">Pipeline processors</param>
      <param name="legend.placement">right</param>
        <module name="JobProgressIndicator"/>
        <module name="FlashChart">
          <param name="width">100%</param>
          <param name="height">300px</param>
        </module>
    </module>
</module>

second switcher child

<module name="HiddenSearch" group="KB Indexed by sourcetype" autoRun="True">
  <param name="search">index=_internal source=*metrics.log component=metrics group=per_sourcetype_thruput | chart sum(kb) by series | sort -sum(kb) | head 10</param>
  <param name="earliest">-1h</param>
    <module name="HiddenChartFormatter">
       <param name="chart">bar</param>
       <param name="primaryAxisTitle.text">Sourcetype</param>
       <param name="secondaryAxisTitle.text">KB Indexed</param>
       <param name="legend.placement">none</param>
         <module name="JobProgressIndicator"/>
         <module name="FlashChart">
           <param name="width">100%</param>
           <param name="height">300px</param>
         </module>
     </module>
</module>

third switcher child

<module name="HiddenSearch" group="eps Indexed over time" autoRun="True">
  <param name="search">index=_internal source=*metrics.log component=metrics group=per_sourcetype_thruput | timechart avg(eps) by series</param>
  <param name="earliest">-1h</param>
    <module name="StaticContentSample">
      <param name="text">On this one I've thrown in some static text to describe the elements.</param>
    </module>
    <module name="HiddenChartFormatter">
      <param name="chart">line</param>
      <param name="primaryAxisTitle.text">Sourcetype</param>
      <param name="secondaryAxisTitle.text">events per second</param>
      <param name="legend.placement">right</param>
        <module name="JobProgressIndicator"/>
        <module name="FlashChart">
          <param name="width">100%</param>
          <param name="height">300px</param>
        </module>
     </module>
</module>

fourth switcher child

Instead of using HiddenSavedSearch, this pattern uses HiddenSearch driven by a TimeRangePicker. Instead of setting to autoRun=true, this search will not actually run until given user input.

<module name="TimeRangePicker">
  <param name="searchWhenChanged">True</param>
  <param name="selected">All time</param>
    <module name="HiddenSearch" autoRun="True">
      <param name="search">| dbinspect bins=400</param>
        <module name="HiddenChartFormatter">
          <param name="chart">line</param>
          <param name="primaryAxisTitle.text">Time</param>
          <param name="chartTitle">Distribution of index buckets over time</param>
            <module name="JobProgressIndicator"/>
            <module name="FlashChart"/>
        </module>
     </module>
</module>

This documentation applies to the following versions of Splunk: 4.0 , 4.0.1 , 4.0.2 , 4.0.3 , 4.0.4 , 4.0.5 , 4.0.6 , 4.0.7 , 4.0.8 , 4.0.9 , 4.0.10 , 4.0.11 , 4.1 , 4.1.1 , 4.1.2 , 4.1.3 , 4.1.4 , 4.1.5 , 4.1.6 , 4.1.7 , 4.1.8 View the Article History for its revisions.


You must be logged into splunk.com in order to post comments. Log in now.

Was this documentation topic helpful?

If you'd like to hear back from us, please provide your email address:

We'd love to hear what you think about this topic or the documentation as a whole. Feedback you enter here will be delivered to the documentation team.

Feedback submitted, thanks!