Splunk Search

finding percentage

rabrahaham
Engager

Good Day all, 

I would like to find the percentage of devices that has updated. The way I would like to do this is to first search index=main | stats dc(Host_Name). This would give me the total number of host names that are sending data to splunk. Out of that I would like to find out what percentage of those is updated. I can search index=main update* | stats dc(Host_Name) and it will give the number of devices that have updated. But how will I find the percentage of devices that have updated? Normally it would be (devices updated/total devices)*100. For this search how do we craft the search?

Thanks

 

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Here is one way to combine the two searches.

index=main
| eval update=if(searchmatch("update*"), Host_Name, NULL) 
| stats dc(update) as updated, dc(Host_Name) as total 
| fillnull value=0 updated 
| eval pct=round((updated*100)/total,2)
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Here is one way to combine the two searches.

index=main
| eval update=if(searchmatch("update*"), Host_Name, NULL) 
| stats dc(update) as updated, dc(Host_Name) as total 
| fillnull value=0 updated 
| eval pct=round((updated*100)/total,2)
---
If this reply helps you, Karma would be appreciated.
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!

Federated Search for Snowflake Is Now Generally Available on Splunk Cloud Platform

Unlocking Data-In-Place Search Across Splunk and Snowflake  Enterprise data is increasingly distributed across ...

Help Us Build Better Splunk Regex Puzzles (And Win Prizes!)

If you’ve spent any time in the Splunk Community Slack, you’ve likely seen our resident Splunk Trust ...

Fuel Your Journey: What’s Waiting for You at the .conf26 Acceleration Station

Navigating the show floor at .conf26 isn't just about keynotes and technical breakout sessions; it's also ...