Dashboards & Visualizations

How to use multiple tokens in the same search?

pierra56
Explorer

Hi,

I would like to automate the search results Next the sourcetype but also according to the source IP address.
The code:

<form>





All


<![CDATA[|metadata type=sourcetypes index= | stats count by sourcetype]]>






Top 5 source
index=* sourcetype="$sourcetype$" src="$src$"| stats sum(sent) as send sum(rcvd) as receive by dst | sort - send,receive | head 10



Have you any idea?

1 Solution

somesoni2
Revered Legend

Try this

<form>
  <label>Dynamic Source</label>
  <fieldset autoRun="true">
    <input type="dropdown" token="sourcetype" searchWhenChanged="false">
      <label>Sourcetype</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype">
        <![CDATA[|metadata type=sourcetypes index=* | stats count by sourcetype]]>
      </populatingSearch>
    </input>
    <input type="text" token="ipAddress">
      <label>IP Address(format XXX.XXX.XXX.XXX)</label> 
      <default /> 
  </input>
  </fieldset>
  <row>
    <panel>
      <table>
      <title>Top 5 source</title>
      <searchString>index=* sourcetype="$sourcetype$" src="$ipAddress$"| stats sum(sent) as send sum(rcvd) as receive by dst | sort - send,receive | head 10 </searchString>
      </table>  
    </panel>
    </row>
</form>

View solution in original post

somesoni2
Revered Legend

Try this

<form>
  <label>Dynamic Source</label>
  <fieldset autoRun="true">
    <input type="dropdown" token="sourcetype" searchWhenChanged="false">
      <label>Sourcetype</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype">
        <![CDATA[|metadata type=sourcetypes index=* | stats count by sourcetype]]>
      </populatingSearch>
    </input>
    <input type="text" token="ipAddress">
      <label>IP Address(format XXX.XXX.XXX.XXX)</label> 
      <default /> 
  </input>
  </fieldset>
  <row>
    <panel>
      <table>
      <title>Top 5 source</title>
      <searchString>index=* sourcetype="$sourcetype$" src="$ipAddress$"| stats sum(sent) as send sum(rcvd) as receive by dst | sort - send,receive | head 10 </searchString>
      </table>  
    </panel>
    </row>
</form>

pierra56
Explorer

Again thanks.

0 Karma

pierra56
Explorer

yes, it's true a textbox would be more practical.

0 Karma

somesoni2
Revered Legend

You want a dropdown for source IPs or a textbox (manual input)?

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...