Splunk Search

How to edit my search to filter and populate an input field only with host names with ABC in the value?

sushmitha_mj
Communicator

I am trying to populate an input field using the following lines in XML dashboard source

   <populatingSearch fieldForValue="host" fieldForLabel="host">
    <![CDATA[|metadata type=hosts index=os host="ABC*"]]>
  </populatingSearch>

I am adding host="ABC*" for it to display only host names having ABC, but it is still displaying all the host names. How do I make it display just ABC host names?

0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

Keep it simple and just filter the output of the metadata command with a search command.

<populatingSearch fieldForValue="host" fieldForLabel="host">
  <![CDATA[|metadata type=hosts index=os | search host="ABC*"]]>
</populatingSearch>

View solution in original post

sideview
SplunkTrust
SplunkTrust

Keep it simple and just filter the output of the metadata command with a search command.

<populatingSearch fieldForValue="host" fieldForLabel="host">
  <![CDATA[|metadata type=hosts index=os | search host="ABC*"]]>
</populatingSearch>

sushmitha_mj
Communicator

@sideview
Works !! Thanks...

0 Karma

gyslainlatsa
Motivator

I would like to know if my new proposed answers do not work? thanks

0 Karma

gyslainlatsa
Motivator

hi sushmitha_mj,
try this

    <populatingSearch fieldForValue="host" fieldForLabel="host">
     <![CDATA[|metadata type=hosts index=os host=* |stats count (host) | where like(host,"ABC%")]]>
   </populatingSearch> 

If this does not work, try to use stats count by host as this:

 <populatingSearch fieldForValue="host" fieldForLabel="host">
         <![CDATA[|metadata type=hosts index=os host=* |stats count by host  | where like(host,"ABC%")]]>
       </populatingSearch> 

sushmitha_mj
Communicator

@gyslainlatsa
Does not work. It does not list the hosts at all. It just lists "all" and when I select that,
all hosts are displayed.

0 Karma

gyslainlatsa
Motivator

remove values() and put count() as specified above

0 Karma

sushmitha_mj
Communicator

@gyslainlatsa
Your second solution also worked!! Thanks...

0 Karma
Get Updates on the Splunk Community!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...