Splunk Dev

Can you help me count the values of two different fields?

jip31
Motivator

Hello

I use the code below in order to count the number of hosts by OS and by build. But, it doesn't work.
Could you help me please??

host=*
index="windows" sourcetype="wineventlog" 
SourceName="*" Type="Critique" OR Type="*"  

| dedup host   

| stats count by host   

| join host [search index=windows sourcetype=winregistry  key_path="\\registry\\machine\\software\\wow6432node\\x\\master\\WindowsVersion" 
 OR 
key_path="\\registry\\machine\\software\\microsoft\\windows nt\\currentversion\\ReleaseId"
 |eval OS=if(key_path=="\\registry\\machine\\software\\wow6432node\\x\\master\\WindowsVersion",data, null), 
Build=if(key_path=="\\registry\\machine\\software\\microsoft\\windows nt\\currentversion\\ReleaseId",data,null) 

| stats values(data) as OS by host]
| stats count values(host) by OS, Build

| rename count as Total
| table OS Build Total
| sort -Total limit=10
Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

host=*
 index="windows" sourcetype="wineventlog"  SourceName="*" Type="Critique" OR Type="*"  
  | dedup host    
 | stats count by host  
 | append [search index=windows sourcetype=winregistry  key_path="\\registry\\machine\\software\\wow6432node\\x\\master\\WindowsVersion" 
  OR 
 key_path="\\registry\\machine\\software\\microsoft\\windows nt\\currentversion\\ReleaseId"
  |eval OS=if(key_path=="\\registry\\machine\\software\\wow6432node\\x\\master\\WindowsVersion",data, null), 
 Build=if(key_path=="\\registry\\machine\\software\\microsoft\\windows nt\\currentversion\\ReleaseId",data,null) 
 | stats latest(OS) as OS latest(Build) as Build by host ]
| stats values(OS) as OS values(Build) as Build by host
| stats count as Total by OS Build
 | sort -Total limit=10

View solution in original post

0 Karma

inventsekar
SplunkTrust
SplunkTrust

i think
| stats count values(host) by OS, Build
is wrong..

try -
index=* | stats values(host) as HostCount by OS Build

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
0 Karma

somesoni2
Revered Legend

Give this a try

host=*
 index="windows" sourcetype="wineventlog"  SourceName="*" Type="Critique" OR Type="*"  
  | dedup host    
 | stats count by host  
 | append [search index=windows sourcetype=winregistry  key_path="\\registry\\machine\\software\\wow6432node\\x\\master\\WindowsVersion" 
  OR 
 key_path="\\registry\\machine\\software\\microsoft\\windows nt\\currentversion\\ReleaseId"
  |eval OS=if(key_path=="\\registry\\machine\\software\\wow6432node\\x\\master\\WindowsVersion",data, null), 
 Build=if(key_path=="\\registry\\machine\\software\\microsoft\\windows nt\\currentversion\\ReleaseId",data,null) 
 | stats latest(OS) as OS latest(Build) as Build by host ]
| stats values(OS) as OS values(Build) as Build by host
| stats count as Total by OS Build
 | sort -Total limit=10
0 Karma

jip31
Motivator

thanks a lot it s perfect

0 Karma
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...