Splunk Search

How to get the percentage of each HTTP status code

bryceweb22
Path Finder

I would like to get the percentage of each HTTP status code. I have the count of each status code that appears and I just need a way to divide each code by the total number so I can get the percentage.

0 Karma
1 Solution

jazzypai
Path Finder

Assuming you have a table reflecting a column of http codes along with a column of count (as "count"), try the following adding the following to your search query;

| eventstats sum(count) as total
| eval code_per = round((count / total)*100,2)."%"
| fields - total

View solution in original post

jazzypai
Path Finder

Assuming you have a table reflecting a column of http codes along with a column of count (as "count"), try the following adding the following to your search query;

| eventstats sum(count) as total
| eval code_per = round((count / total)*100,2)."%"
| fields - total

bryceweb22
Path Finder

That didn't completely work for me, but I did use the sum(count) as total which gave me what I was looking for. Thanks!

0 Karma

jazzypai
Path Finder

Copy.

If you want to provide more information we can attempt to work further into making sure it works correctly otherwise I'm glad you were able to make it work and if satisfied, please mark answered 🙂

Have a good day!

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...