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!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...