Splunk Search

Subsearch on results

omgwut56k
Path Finder

Hi Answers, hopefully someone can help me figure this out.

I need to see a list of all results and a distinct count of all programs running for each host, and specifically which computers,users are running a specific program e.g logon.exe

Example data:

host=computer1 user=joe,user program=Logon.exe
host=computer1 user=joe,user program=word.exe
host=computer1 user=joe,user program=notepad.exe

host=computer2 user=jane,user program=outlook.exe
host=computer2 user=jane,user program=lotus.exe
host=computer2 user=jane,user program=notepad.exe

host=computer3 user=dave,user program=outlook.exe
host=computer3 user=dave,user program=lotus.exe
host=computer3 user=dave,user program=notepad.exe

Expected results,
computer_name user, count_of_running_programs count_of_logon.exe

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I think you can do this without a subsearch. Try index=foo | stats dc(program) as programCount, dc(eval(program="Logon.exe")) as logonCount by host, user | table host user programCount logonCount.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

I think you can do this without a subsearch. Try index=foo | stats dc(program) as programCount, dc(eval(program="Logon.exe")) as logonCount by host, user | table host user programCount logonCount.

---
If this reply helps you, Karma would be appreciated.

omgwut56k
Path Finder

Perfect! Thank you.

0 Karma

omgwut56k
Path Finder

Bonus points.. if you can help me identify users logged into multiple computers.. Bonus Bonus points if I can display both computes in a multi-value field as a result of the stats command.

0 Karma

woodcock
Esteemed Legend

Bonus points:

index=foo | stats dc(program) as programCount, dc(eval(program="Logon.exe")) as logonCount by host, user | table host user programCount logonCount | eventstats values(hosts) AS hosts by user
0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...