Splunk Search

How to edit my search to find the percentage of total bytes used for each URI path in the top 10?

dovelsh12223621
Path Finder

Hi everyone,

I need your help. My current search is like this:

index="ihs_test"  uri_path="*.jhtml" OR uri_path="*.html"  | transaction clientip  | search bytes!="-" | stats sum(bytes) as total_usebytes |appendcols [search index="ihs_test"  uri_path="*.jhtml" OR uri_path="*.html"  | transaction clientip   | search bytes!="-" | stats sum(bytes) as total_usebytes_by_uri_path  by uri_path] | eval percentage=total_usebytes_by_uri_path/total_usebytes

I need to know the percentage of total bytes used for every page in the top 10. How do I do this?

Tags (3)
0 Karma
1 Solution

lguinn2
Legend

Try this

index="ihs_test"  uri_path="*.jhtml" OR uri_path="*.html"  
| transaction clientip  
| search bytes!="-" 
| stats sum(bytes) as as total_usebytes_by_uri_path  by uri_path
| eventstats sum(total_usebytes_by_uri_path) as total_usebytes
| eval percentage=total_usebytes_by_uri_path/total_usebytes
| sort 10 -percentage 

Without the subsearch, this should run dramatically faster. Why do you need the transaction command at all?

View solution in original post

ppablo
Retired

Hi @dovelsh12223621

Just following up with this post, but did @lguinn's search below answer your question? If yes, don't forget to resolve the post by clicking "Accept" directly below her answer and upvote it by clicking the up arrow to the left of the answer.

0 Karma

lguinn2
Legend

Try this

index="ihs_test"  uri_path="*.jhtml" OR uri_path="*.html"  
| transaction clientip  
| search bytes!="-" 
| stats sum(bytes) as as total_usebytes_by_uri_path  by uri_path
| eventstats sum(total_usebytes_by_uri_path) as total_usebytes
| eval percentage=total_usebytes_by_uri_path/total_usebytes
| sort 10 -percentage 

Without the subsearch, this should run dramatically faster. Why do you need the transaction command at all?

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, ...