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
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>
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>
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?
If you already have an existing dashboard(or rather form), you can copy the "" to
. I hope this is what you're asking.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.
What version of Splunk do you use?