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
Get Updates on the Splunk Community!

BORE at .conf25

Boss Of Regular Expression (BORE) was an interactive session run again this year at .conf25 by the brilliant ...

OpenTelemetry for Legacy Apps? Yes, You Can!

This article is a follow-up to my previous article posted on the OpenTelemetry Blog, "Your Critical Legacy App ...

UCC Framework: Discover Developer Toolkit for Building Technology Add-ons

The Next-Gen Toolkit for Splunk Technology Add-on Development The Universal Configuration Console (UCC) ...