Dashboards & Visualizations

Time Input Dependence in a Dashboard

Chintan_m
Explorer

I have a dashboard with multiple panels each requiring their separate time inputs. But, the dashboard also needs a common time input.

So, the requirements are

  • When the dashboard loads, every panel should have the same time range i.e., default time range of the common time range picker.
  • If the time range picker is changed for a specific panel is changed then it should override the common time range and run only the specified panel again for the new time range.
  • If the common time range picker is changed, it should override the panel specific time ranges and every panel should run again.
  • Basically, the latest changes should override the previous state always. The only catch is that when a panel specific change occurs it only affects that specific panel but when a change us made to common time range picker it will affect all the panels.

Here is the Dashboard XML that I am currently using but its's not giving me what I need.

 

<form>
  <label>EDTC Reporting</label>
  <description>EDTC requirements for new application</description>
  <fieldset submitButton="false" autoRun="true">
    <input type="time" token="field1" searchWhenChanged="true">
      <label></label>
      <default>
        <earliest>0</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel>
      <input type="time" token="time1" searchWhenChanged="true">
        <label></label>
        <default>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </default>
      </input>
      <chart>
        <title>Average Response Time per Module</title>
        <search>
          <query>index=main
| rex field=processingTime "\[(?&lt;responseTime&gt;\d*)"
| stats avg(responseTime) by module</query>
          <earliest>$time1.earliest$</earliest>
          <latest>$time1.latest$</latest>
        </search>
        <option name="charting.axisTitleX.text">Module</option>
        <option name="charting.axisTitleY.text">Average Response Time</option>
        <option name="charting.axisY.scale">linear</option>
        <option name="charting.chart">column</option>
        <option name="charting.chart.stackMode">default</option>
        <option name="charting.drilldown">none</option>
      </chart>
    </panel>
  </row>
  <row>
    <panel>
      <input type="time" token="time2" searchWhenChanged="true">
        <label></label>
        <default>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </default>
      </input>
      <chart>
        <title>Module wise Error Rate</title>
        <search>
          <query>index=main
| where isnotnull(errorCode)
| stats count as count2 by module
| join type=inner module
[
search index=main
| stats count as count1 by module
]
| eval errorRate = (count2/count1*100)
| table module errorRate</query>
          <earliest>$time2.earliest$</earliest>
          <latest>$time2.latest$</latest>
        </search>
        <option name="charting.axisTitleY.text">Error Rate</option>
        <option name="charting.axisY.maximumNumber">100</option>
        <option name="charting.axisY.minimumNumber">0</option>
        <option name="charting.chart">column</option>
        <option name="charting.drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </chart>
    </panel>
  </row>
  <row>
    <panel>
      <input type="time" token="time3" searchWhenChanged="true">
        <label></label>
        <default>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </default>
      </input>
      <chart>
        <title>Module wise Security Exceptions</title>
        <search>
          <query>index=main 
| where match(displayMessage,"Resource Unavailable")
| stats count by module</query>
          <earliest>$time3.earliest$</earliest>
          <latest>$time3.latest$</latest>
        </search>
        <option name="charting.chart">column</option>
        <option name="charting.drilldown">none</option>
      </chart>
    </panel>
  </row>
  <row>
    <panel>
      <input type="time" token="time4" searchWhenChanged="true">
        <label></label>
        <default>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </default>
      </input>
      <table>
        <title>Unique Users</title>
        <search>
          <query>index=main 
| dedup unique_name
| table unique_name</query>
          <earliest>$time4.earliest$</earliest>
          <latest>$time4.latest$</latest>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <input type="time" token="time5" searchWhenChanged="true">
        <label></label>
        <default>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </default>
      </input>
      <table>
        <title>Most Used Features</title>
        <search>
          <query>index=main
| dedup _raw
| top limit=10 path</query>
          <earliest>$time5.earliest$</earliest>
          <latest>$time5.latest$</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <input type="time" token="time6" searchWhenChanged="true">
        <label></label>
        <default>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
        </default>
      </input>
      <table>
        <title>Least Used Feature</title>
        <search>
          <query>index=main
| dedup _raw
| rare limit=10 path</query>
          <earliest>$time6.earliest$</earliest>
          <latest>$time6.latest$</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

 

 And, below shown is what I get when I first open the dashboard.

Chintan_m_0-1615799979348.png

 

Labels (4)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Add this in your XML after the <description> element in the first few lines and remove all the timeX <default> settings.

  <search>
    <query>
| makeresults
| addinfo
| eval info_max_time=if(info_max_time="+Infinity", "now", info_max_time)
</query>
    <done>
      <set token="time1.earliest">$result.info_min_time$</set>
      <set token="time1.latest">$result.info_max_time$</set>
      <set token="time2.earliest">$result.info_min_time$</set>
      <set token="time2.latest">$result.info_max_time$</set>
      <set token="time3.earliest">$result.info_min_time$</set>
      <set token="time3.latest">$result.info_max_time$</set>
      <set token="time4.earliest">$result.info_min_time$</set>
      <set token="time4.latest">$result.info_max_time$</set>
      <set token="time5.earliest">$result.info_min_time$</set>
      <set token="time5.latest">$result.info_max_time$</set>
      <set token="time6.earliest">$result.info_min_time$</set>
      <set token="time6.latest">$result.info_max_time$</set>
    </done>
    <earliest>$field1.earliest$</earliest>
    <latest>$field1.latest$</latest>
  </search>

This will work out the start/end time for the default time and then set all the other time tokens for other panels. Then if you change the default, this search will rerun and will set all the panel times, whereas if you change the panel time it will change that panel only.

However, it will not change the UI in the panel for all panel time pickers when you change the default. I believe you will have to write some javascript to do that.

Hope this helps

 

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Add this in your XML after the <description> element in the first few lines and remove all the timeX <default> settings.

  <search>
    <query>
| makeresults
| addinfo
| eval info_max_time=if(info_max_time="+Infinity", "now", info_max_time)
</query>
    <done>
      <set token="time1.earliest">$result.info_min_time$</set>
      <set token="time1.latest">$result.info_max_time$</set>
      <set token="time2.earliest">$result.info_min_time$</set>
      <set token="time2.latest">$result.info_max_time$</set>
      <set token="time3.earliest">$result.info_min_time$</set>
      <set token="time3.latest">$result.info_max_time$</set>
      <set token="time4.earliest">$result.info_min_time$</set>
      <set token="time4.latest">$result.info_max_time$</set>
      <set token="time5.earliest">$result.info_min_time$</set>
      <set token="time5.latest">$result.info_max_time$</set>
      <set token="time6.earliest">$result.info_min_time$</set>
      <set token="time6.latest">$result.info_max_time$</set>
    </done>
    <earliest>$field1.earliest$</earliest>
    <latest>$field1.latest$</latest>
  </search>

This will work out the start/end time for the default time and then set all the other time tokens for other panels. Then if you change the default, this search will rerun and will set all the panel times, whereas if you change the panel time it will change that panel only.

However, it will not change the UI in the panel for all panel time pickers when you change the default. I believe you will have to write some javascript to do that.

Hope this helps

 

Chintan_m
Explorer

Yes, it works as you anticipated. But the non reflection of changes to UI is still a problem. Thank you so much!

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...