Dashboards & Visualizations

How to get Server name based dashboard

digitalrg
New Member

Hello,

I am forwarding a log file with some data in it and using below search string:
sourcetype=dhap source="/var/log/dhap-log" "WAIT"
Once I run this search, under Hosts field I get 2 entries for the servers from where i am getting the results. I want to save this search to a Dashboard panel where it should give me a drop-down menu for the entries from the "host" field.

Please help me on this.

Thanks,
Raghav

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try. (simple xml form with host dropdown)

<form>
  <label>Dynamic Host</label>
  <fieldset autoRun="true" >
      <input type="time" />
    <input type="dropdown" token="sourcetype">
      <label>Host</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="host" fieldForLabel="host">
        <![CDATA[| metasearch sourcetype=dhap source="/var/log/dhap-log" | stats count by host | table host ]]>
      </populatingSearch>
    </input>
  </fieldset>
  <row>
    <event>
      <title>Top 5 source</title>
      <searchString>sourcetype=dhap source="/var/log/dhap-log" "WAIT" host="$host$" </searchString>      
      <option name="count">10</option>
    </event>
  </row>
</form>

Answer no 2: with 2 dropdown source and sourcetype for base search index=main.

<form>
  <label>Dynamic Host</label>
  <fieldset autoRun="true" >
      <input type="time" />
    <input type="dropdown" token="sourcetype">
      <label>SourceType</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype">
        <![CDATA[| metasearch index=main | stats count by sourcetype ]]>
      </populatingSearch>
    </input>
<input type="dropdown" token="source">
      <label>Source</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="source" fieldForLabel="source">
        <![CDATA[| metasearch index=main | stats count by source ]]>
      </populatingSearch>
    </input>
  </fieldset>
  <row>
    <event>
      <title>Top 5 source</title>
      <searchString>index=main sourcetype="$sourcetype$" source="$source$" | rest of your search </searchString>      
      <option name="count">10</option>
    </event>
  </row>
</form>

View solution in original post

somesoni2
Revered Legend

Give this a try. (simple xml form with host dropdown)

<form>
  <label>Dynamic Host</label>
  <fieldset autoRun="true" >
      <input type="time" />
    <input type="dropdown" token="sourcetype">
      <label>Host</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="host" fieldForLabel="host">
        <![CDATA[| metasearch sourcetype=dhap source="/var/log/dhap-log" | stats count by host | table host ]]>
      </populatingSearch>
    </input>
  </fieldset>
  <row>
    <event>
      <title>Top 5 source</title>
      <searchString>sourcetype=dhap source="/var/log/dhap-log" "WAIT" host="$host$" </searchString>      
      <option name="count">10</option>
    </event>
  </row>
</form>

Answer no 2: with 2 dropdown source and sourcetype for base search index=main.

<form>
  <label>Dynamic Host</label>
  <fieldset autoRun="true" >
      <input type="time" />
    <input type="dropdown" token="sourcetype">
      <label>SourceType</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="sourcetype" fieldForLabel="sourcetype">
        <![CDATA[| metasearch index=main | stats count by sourcetype ]]>
      </populatingSearch>
    </input>
<input type="dropdown" token="source">
      <label>Source</label>
      <choice value="*">All</choice>
      <default>*</default>
      <populatingSearch fieldForValue="source" fieldForLabel="source">
        <![CDATA[| metasearch index=main | stats count by source ]]>
      </populatingSearch>
    </input>
  </fieldset>
  <row>
    <event>
      <title>Top 5 source</title>
      <searchString>index=main sourcetype="$sourcetype$" source="$source$" | rest of your search </searchString>      
      <option name="count">10</option>
    </event>
  </row>
</form>

digitalrg
New Member

Thanks Rahul Roy.
One more query I have.
Lets say I want to get a 2 dropdowns like "Source" and "Sourcetype" with the basic search as index=main
How do I do it?

0 Karma

rahulroy_splunk
Path Finder

If you already have an existing dashboard(or rather form), you can copy the "" to

tag of that dashboard and copy "
...
" to section after
. I hope this is what you're asking.

digitalrg
New Member

Thanks somesoni2.
This works well after changing token="host"
However can you please tell me if the same thing i want to have it only as a Dashboard panel how can i modify this?

Thanks in advance.

0 Karma

tom_frotscher
Builder

What version of Splunk do you use?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Automated Threat Analysis: Available in ES Premier

Automated Threat Analysis: Centralize and Accelerate Phishing Investigations in Splunk Enterprise ...

What’s New in Splunk AI: Volume 02

Welcome to the second edition of “What’s New in Splunk AI” where we look at the latest and greatest updates, ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...