Dashboards & Visualizations

How to pass values from a dashboard input to a saved search?

karthik40us
Explorer

All,

I have the below source code:

<search ref="Name of my Saved Report which is scheduled hourly"></search>

How do I pass a dashboard input for the above saved search which is scheduled hourly?

For example: if my above search ref lists all hosts within my environment and I get a dashboard input say "Linux/Windows", I want the scheduled saved report to bring back depending upon the input that was chosen from the dashboard.

Any thoughts?

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this. Basically make your search which is using a report as source, as base search and use the postprocess search for your panels which can utilize the token to filter the results. My report here is countbysourcetype and has following query

index=_internal | stats count by sourcetype


<form>
  <label>Call SavedSearch and Filter</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="sourcetype">
      <search>
        <query>| tstats count WHERE index=_internal by sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
    </input>
  </fieldset>
  <search id="basesearch" ref="countbysourcetype"></search>
  <row>
    <panel>
      <table>
        <title>countbysourcetype</title>
        <search base="basesearch" ><query>where sourcetype="$sourcetype$"</query></search>
        <option name="wrap">undefined</option>
        <option name="rowNumbers">undefined</option>
        <option name="drilldown">row</option>
      </table>
    </panel>
  </row>
</form>

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this. Basically make your search which is using a report as source, as base search and use the postprocess search for your panels which can utilize the token to filter the results. My report here is countbysourcetype and has following query

index=_internal | stats count by sourcetype


<form>
  <label>Call SavedSearch and Filter</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="sourcetype">
      <search>
        <query>| tstats count WHERE index=_internal by sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
    </input>
  </fieldset>
  <search id="basesearch" ref="countbysourcetype"></search>
  <row>
    <panel>
      <table>
        <title>countbysourcetype</title>
        <search base="basesearch" ><query>where sourcetype="$sourcetype$"</query></search>
        <option name="wrap">undefined</option>
        <option name="rowNumbers">undefined</option>
        <option name="drilldown">row</option>
      </table>
    </panel>
  </row>
</form>
0 Karma

karthik40us
Explorer

It worked perfectly for table dashboard visual but did not work for PIE charts as the pie charts went after stats count and the "Where" clause was added at the very end after stats count so it came up with NO RESULTS all the time. 🙂

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...