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!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...