Splunk Search

Help for Doing a Count from a Dropdown List

jip31
Motivator

hello

I use the search below which works fine

[| inputlookup host.csv 
    | table host] index="x" sourcetype=XmlWinEventLog source="XmlWinEventLog:System" EventCode=1067 (Level=1 OR Level=2 OR Level=3) 
| dedup host 
| lookup lookup_cmdb_fo_all.csv HOSTNAME as host output SITE 
| search SITE=$tok_filtersite|s$ 
| stats count as NbEventCodeHost 
| appendcols 
    [| inputlookup host.csv 
    | stats count as NbIndHost] 
| eval Perc=round((NbEventCodeHost/NbIndHost)*100,2). " %" + " / " + NbIndHost + " machines " 
| table Perc

But I need an improvement for NbIndHost
Actually this value is just a global count in inputlookup host.csv
What I need is to do a count from the site selected in my dropdown filter (| search SITE=$tok_filtersite|s$ )
It means that I have to match
So I tried to do something like that :

[| inputlookup host.csv 
    | table host] index="ai-wkst-wineventlog-fr" sourcetype=XmlWinEventLog source="XmlWinEventLog:System" EventCode=1067 (Level=1 OR Level=2 OR Level=3) 
| dedup host 
| lookup lookup_cmdb_fo_all.csv HOSTNAME as host output SITE 
| search SITE=$tok_filtersite|s$ 
| stats count as NbEventCodeHost 
| appendcols 
    [| inputlookup host.csv  | lookup lookup_cmdb_fo_all.csv HOSTNAME as host output SITE 
    | search SITE=$tok_filtersite|s$ 
    | stats count as NbIndHost 
   ] 
| eval Perc=round((NbEventCodeHost/NbIndHost)*100,2). " %" + " / " + NbIndHost + " machines " 
| table Perc

It works BUT
When I m doing [| inputlookup host.csv | | stats count as NbIndHost ] I have 40 machines
But when I execute my search with * (so it means all machines in the CSV file) in the dropdown menu I have only 35 machines
Have you an idea where are the 5 machines lacking??

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

Hi @jip31,
Better way to ask here is give your lookup data and explain your requirement, and Splunk Ninjas here will help you write and understand the query. As it is just dropdown query and you are using lookup commnad thrice.

0 Karma

somesoni2
Revered Legend

Do all your host.csv value have SITE associated with it? You can check it by running this

| inputlookup host.csv  | lookup lookup_cmdb_fo_all.csv HOSTNAME as host output SITE 
| table host SITE

jip31
Motivator

you are right contrary of what said the business, some host have no site, so my search is good many thanks

0 Karma

amitm05
Builder

Cant see any visible fault here.
Guessing, if there can be a size limit for drop down. Can you check by sorting your results if you are able to see missing ones then.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: The Agentic SOC: Trust Before Autonomy

AI is fundamentally changing security operations, but true progress requires more than just automation—it ...

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...

Defend at Machine Speed: Your Guide to Security Sessions at .conf26

Splunk .conf26   With threats moving at machine speed and attack surfaces expanding across hybrid ...