Dashboards & Visualizations

TimeRangePicker times in nested HiddenSearch - how?

bowesmana
SplunkTrust
SplunkTrust

I had a simple XML Dashboard form with a company dropdown and a time range

<?xml version="1.0" encoding="UTF-8"?>
<form>
  <label>Excel Export dashboard Simple 2</label>
  <description/>
  <searchTemplate>sourcetype="completions_*" $company$</searchTemplate>
  <fieldset>
    <input type="dropdown" token="company" searchWhenChanged="true">
      <label>Select a Company:</label>
      <prefix>Company="</prefix>
      <suffix>"</suffix>
      <default>*</default>
      <choice value="*">All</choice>
      <populatingSearch fieldForValue="Company" fieldForLabel="Co_Name">
        <![CDATA[ | inputlookup rich-co ]]>
      </populatingSearch>
    </input>
    <input type="time" searchWhenChanged="true">
      <label>Select a time</label>
      <default>
        <earliestTime>-1mon@mon</earliestTime>
        <latestTime>@mon</latestTime>
      </default>
    </input>
  </fieldset>
  <row>
    <table>
      <title>Excel Completion Data</title>
      <searchString>sourcetype="completions_*" $company$</searchString>
      <earliestTime>$earliest$</earliestTime>
      <latestTime>$latest$</latestTime>
    </table>
  </row>
</form>

I have converted this to Advanced XML and it no longer works, it gives the red bar error Invalid earlier_time.

It seems it is caused by this

<module name="TimeRangePicker">
  <param name="label">Select a time</param>
  <param name="searchWhenChanged">True</param>
  <module name="SubmitButton" layoutPanel="viewHeader">
    <param name="label">Search</param>
    <param name="updatePermalink">True</param>
    <param name="allowSoftSubmit">True</param>
    <param name="visible">True</param>
    <module name="HiddenSearch" layoutPanel="panel_row1_col1" group="Excel Completion Data" autoRun="False">
      <param name="groupLabel">Excel Completion Data</param>
      <param name="latest">$latest$</param>
      <param name="search">sourcetype="completions_*" $company$</param>
      <param name="earliest">$earliest$</param>

In particular the latest and earliest param elements. If I change those to @mon and -mon@mon, it works OK but then it ignores the time range picker.

So, how do I get the time range picker values into the nested HiddenSearch?

sideview
SplunkTrust
SplunkTrust

The Simple XML to Advanced XML conversion for <form> views has always been flaky.

However I think here you've discovered a newer class of problems where the new 6.0 simple XML renderer is actually capable of doing something that the core Splunk Advanced XML system is not really able to do. To back up a second - in 5.0 and earlier the Simple XML was kind of a macro layer that was implemented at runtime by some equivalent Advanced XML config. In 6.0 the Simple XML is actually rendered by a completely different UI system. This puts the "conversion" utility into a strange situation - where the supported range of configurations for simple XML and advanced XML may no longer match well.

Fortunately I recommend, across the board, never converting Simple XML views to Advanced XML views using the default converter. The core advanced xml systems are limited inconsistent and pretty bewildering, and the converter introduces a certain amount of cruft into the XML that makes it even worse.

Instead it is easier to get familiar with the latest Sideview Utils app ( http://sideviewapps.com/apps/sideview-utils ) and then rewrite the dashboard in the Advanced XML format, but using Sideview modules. Here is your view rewritten. You may agree with me that it's not really any more complicated than the "simple" xml.

<view autoCancelInterval="90" isVisible="true" onunloadCancelJobs="true" template="dashboard.html">
  <label>Excel Export dashboard Simple 2</label>
  <module name="AccountBar" layoutPanel="appHeader" />
  <module name="AppBar" layoutPanel="appHeader" />
  <module name="SideviewUtils" layoutPanel="appHeader" />

  <module name="Message" layoutPanel="messaging">
    <param name="filter">*</param>
    <param name="maxSize">2</param>
    <param name="clearOnJobDispatch">False</param>
  </module>

  <module name="Search" layoutPanel="panel_row1_col1" autoRun="True">
    <param name="search">| inputlookup rich-co</param>
    <param name="earliest">-1h</param>
    <param name="latest">now</param>

    <module name="Pulldown">
      <param name="name">company</param>
      <param name="label">Select a Company:</param>
      <param name="template">Company="$value$"</param>
      <param name="valueField">Company</param>
      <param name="labelField">Co_Name</param>

      <module name="TimeRangePicker">
        <param name="selected">Last 4 hours</param>

        <module name="Search">
          <param name="search">sourcetype="completions_*" $company$</param>

          <module name="Pager">

            <module name="Table"></module>

          </module>
        </module>
      </module>
    </module>
  </module>
</view>

sideview
SplunkTrust
SplunkTrust

My apologies - I had a typo in my XML and the "name" param of the Pulldown was set wrong. I edited my answer so that the value of the Pulldown's name param is now "company"

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Thanks sideview, I've been trying to get to grips with Advanced XML and Sideview, so that was a good start above. I read that Simple XML is preferred over advanced with v6, but I'm discovering limitations.

BTW, the $company$ above does not work. In my original, $company$ was the term "Company=xxx", where xxx is the Company field from my lookup table, but that does not seem to occur in your example.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Mmm, I took out the params and it works, so obviously it doesn't convert it very well.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...