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
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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
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 ...