Splunk Search

In a statistics table, how do I make it so a row hides when clicked upon?

denys_k
Explorer

Hello guys

I want to hide the row of a table after clicking on a cell on this table. I guess I should look for JS solution
Example: after clicking at "hide me" on 3d row - hide the whole row, how can i implement this?

alt text

0 Karma
1 Solution

niketn
Legend

@denys_k, please try the following run anywhere example which generates a mock up data as per the question and the uses table drilldown with <eval> to set the token to filter unwanted results from the table when action column value is clicked by pulling corresponding id. (PS: The same can also be implemented with slight tweaking to allow filter without adding action column to table when use clicks any other column i.e. id or message in particular row)

<init> section is used to set the filter token to false so that when the table loads all results are displayed. When Hide Me is clicked for a particular row, eval is used to prepare comma separated filter of ids to be removed from table using <eval> and applied to search filter | search NOT id IN ($tokFilterRecord$). Please try out and confirm.

<dashboard>
  <label>Hide Row based on click</label>
  <init>
    <set token="tokFilterRecord">false</set>
  </init>
  <row>
    <panel>
      <title>tokFilterRecord: $tokFilterRecord$</title>
      <table>
        <search>
          <query>| makeresults count=7
| streamstats count as id
| fields - _time
| eval message="Message-".id
| eval action="Hide Me!"
| table id message action
| search NOT id IN ($tokFilterRecord$)</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <drilldown>
          <condition field="action">
            <eval token="tokFilterRecord">if($tokFilterRecord$=="false",$row.id$,$tokFilterRecord$.",".$row.id$)</eval>
          </condition>
        </drilldown>
      </table>
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@denys_k, please try the following run anywhere example which generates a mock up data as per the question and the uses table drilldown with <eval> to set the token to filter unwanted results from the table when action column value is clicked by pulling corresponding id. (PS: The same can also be implemented with slight tweaking to allow filter without adding action column to table when use clicks any other column i.e. id or message in particular row)

<init> section is used to set the filter token to false so that when the table loads all results are displayed. When Hide Me is clicked for a particular row, eval is used to prepare comma separated filter of ids to be removed from table using <eval> and applied to search filter | search NOT id IN ($tokFilterRecord$). Please try out and confirm.

<dashboard>
  <label>Hide Row based on click</label>
  <init>
    <set token="tokFilterRecord">false</set>
  </init>
  <row>
    <panel>
      <title>tokFilterRecord: $tokFilterRecord$</title>
      <table>
        <search>
          <query>| makeresults count=7
| streamstats count as id
| fields - _time
| eval message="Message-".id
| eval action="Hide Me!"
| table id message action
| search NOT id IN ($tokFilterRecord$)</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <drilldown>
          <condition field="action">
            <eval token="tokFilterRecord">if($tokFilterRecord$=="false",$row.id$,$tokFilterRecord$.",".$row.id$)</eval>
          </condition>
        </drilldown>
      </table>
    </panel>
  </row>
</dashboard>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

denys_k
Explorer

Interesting solution with evaluating token in condition. Thanks!

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...