Dashboards & Visualizations

Clear or hide old drilldown panel results from new filter search

wiggler
Explorer

Hi Splunk Masters, I would like to ask some help on how to make the features on my dashboard work. Using the code below, my dashboard shows records and a filters on top where I can search for a specific record from the results of the SQL. The drilldown works but what I want to achieve is whenever I want to do another search, I want to clear the drilldown panel/tables below which I can't it work. Is there anything that I needs to set on the code below?

<form>
  <label>Test Dashboard</label>
  <fieldset autoRun="true">
    <input type="dropdown" token="filter_1">
      <label>filter 1</label>
      <default>*</default>
      <fieldForLabel>filter_1</fieldForLabel>
      <fieldForValue>filter_1</fieldForValue>
      <search>
        <query>| "SQL query here to display records for filter 1 selection" </query>
      </search>
    </input>
    <input type="text" token="filter_2">
      <label>filter 2</label>
      <default>*</default>
    </input>
    <input type="text" token="filter_3">
      <label>filter 3</label>
      <default>*</default>
    </input>
    <input type="dropdown" token="filter 4">
      <label>filter 4</label>
      <default>*</default>
      <fieldForLabel>filter_4</fieldForLabel>
      <fieldForValue>filter_4</fieldForValue>
      <search>
        <query>| "SQL query here to display record for filter 4 selection " </query>
      </search>
    </input>

  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| SQL query here to display all records  | search filter_1="$filter_1$"| search "filter_2"="*$filter_2$*" | search "filter_3"="*$filter_3$*" | search "filter_4"="*$filter_4$*" | table column1, column2, column3 </query>
          <earliest>-1h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>

        <drilldown>
          <set token="column1">$click.value$</set>
          <set token="column2">$row.column2$</set>
          <set token="column3">$row.column3$</set>
           <unset token="column_result"></unset>
        </drilldown>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <table depends="$column_result$">
        <title>$row_column2$ results</title>
        <search>
          <query>| SQL query here to display records based on column search | search "column1"="$column1$" | search column2=$column2$ | search column3=$column3$ | table field1, field2, field3</query>
          <earliest>-1h</earliest>
          <latest>now</latest>
        </search>
        <drilldown>
          <set token="field1">$click.value$</set>
          <set token="field2">$row.field2$</set>
          <set token="field3">$row.field3$</set>
        </drilldown>
      </table>
    </panel>
  </row>
  <row>
    <panel>
      <table depends="$field1$">
        <search>
          <query>| SQL query here to display field1 results | table - - - </query>
          <earliest>-1h</earliest>
          <latest>now</latest>
        </search>
      </table>
    </panel>
  </row>
</form>
Tags (1)
0 Karma
1 Solution

niketn
Legend

@wiggler, you will have to define clearly as to what event changes your search inputs. Also you are asking to clear inputs, however, you have defined default value as asterix (*). Do you want inputs to be defaulted or cleared? You are already using depends to show some panels and also unset tokens in your existing dashboard. Your answer would be a combination of these based on your use case.

If you currently have no event to clear Inputs, you can introduce Checkbox or Radio button input to "Clear Inputs". Following example uses radio button to reset the token which will eventually refresh the panel (panel will not be hidden since default value of drilldown is present). You can achieve something similar with checkbox.

  <fieldset submitButton="false">
    <input type="radio" token="resetTokens" searchWhenChanged="true">
      <label></label>
      <choice value="reset">Reset Inputs</choice>
      <choice value="retain">Retain</choice>
      <default>retain</default>
      <change>
        <condition value="reset">
          <unset token="field1"></unset>
          <unset token="form.field1"></unset>
          <set token="resetTokens">retain</set>
          <set token="form.resetTokens">retain</set>
        </condition>
      </change>
    </input>
    <input type="dropdown" token="field1" searchWhenChanged="true">
      <label>Select Input 1</label>
      <choice value="*">All</choice>
      <choice value="abc">ABC</choice>
      <default>*</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <single depends="$field1$">
        <search>
          <query>| makeresults
          | eval tok_field1="$field1$"
          | table tok_field1</query>
        </search>
      </single>
    </panel>
  </row>

PS: If you want to introduce a button to Refresh tokens and panels, you would need to use Simple XML JS Extension. Please let me know if that is required.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@wiggler, you will have to define clearly as to what event changes your search inputs. Also you are asking to clear inputs, however, you have defined default value as asterix (*). Do you want inputs to be defaulted or cleared? You are already using depends to show some panels and also unset tokens in your existing dashboard. Your answer would be a combination of these based on your use case.

If you currently have no event to clear Inputs, you can introduce Checkbox or Radio button input to "Clear Inputs". Following example uses radio button to reset the token which will eventually refresh the panel (panel will not be hidden since default value of drilldown is present). You can achieve something similar with checkbox.

  <fieldset submitButton="false">
    <input type="radio" token="resetTokens" searchWhenChanged="true">
      <label></label>
      <choice value="reset">Reset Inputs</choice>
      <choice value="retain">Retain</choice>
      <default>retain</default>
      <change>
        <condition value="reset">
          <unset token="field1"></unset>
          <unset token="form.field1"></unset>
          <set token="resetTokens">retain</set>
          <set token="form.resetTokens">retain</set>
        </condition>
      </change>
    </input>
    <input type="dropdown" token="field1" searchWhenChanged="true">
      <label>Select Input 1</label>
      <choice value="*">All</choice>
      <choice value="abc">ABC</choice>
      <default>*</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <single depends="$field1$">
        <search>
          <query>| makeresults
          | eval tok_field1="$field1$"
          | table tok_field1</query>
        </search>
      </single>
    </panel>
  </row>

PS: If you want to introduce a button to Refresh tokens and panels, you would need to use Simple XML JS Extension. Please let me know if that is required.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

wiggler
Explorer

Thanks @niketnilay for the fast reply and solution

0 Karma

niketn
Legend

@wiggler, glad it worked.

If you want to reset tokens based on Submit button or your own HTML button click event, then you can refer the question I have answered after your's. Following uses Simple XML JS Extension and has been created for unsetting two tokens on click of Submit button.

https://answers.splunk.com/answers/559454/how-to-clear-dependent-value-when-start-new-search.html#an...

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...