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 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...