Splunk Search

show percentage as a new field

ranjitbrhm1
Communicator

Hello All, I have a question for you. We have data where the user want to calculate the number of events that have occured for an event name. so i write a query (Just an example)
index=_internal | stats count(sourcetype) as number by name
and i get a result like this
name number
asdf 10
ghjoi 15
kdkd 20

i want to have a third field somehow where it shows that asdf occured 30% ghjoi occured 50% and kdkd occured 20%

name number final percentage
asdf 10 30
ghjoi 15 50
kdkd 20 20

how do i achieve this?

thanks

Tags (2)
0 Karma
1 Solution

harsmarvania57
Ultra Champion

Hi @ranjitbrhm1,

Based on example you have given , can you please try like this

index=_internal | stats count(sourcetype) as number by name
| eventstats sum(number) AS total
| eval percentage=(number/total)*100

View solution in original post

harsmarvania57
Ultra Champion

Hi @ranjitbrhm1,

Based on example you have given , can you please try like this

index=_internal | stats count(sourcetype) as number by name
| eventstats sum(number) AS total
| eval percentage=(number/total)*100

ranjitbrhm1
Communicator

absolutely brilliant. it worked like a charm. thanks XOXO

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...