Splunk Search

How to search Apache access_log data to find bandwidth usage as total number of bytes?

Engager

I can pull the Apache access_log into Splunk, but I can't figure out now to write a search that will give the total number of bytes that Apache sends to browsers over a period of time. Anyone have one to share?

Thanks.

0 Karma
1 Solution

Explorer

Hope this helps you.

Apache access_log sample:
127.0.0.1 - - [22/Jun/2016:15:19:48 -0700] "GET /uri/sample/path HTTP/1.1" 200 20 15515

I created an extracted field called apachebytesize on the second column from the very right. In this example the number of bytes = 20. I change the search to the time frame that I want.

Sample Splunk search:
index=apache host=hostname sourcetype=accesslog | stats sum(apachebyte_size)

View solution in original post

Explorer

Hope this helps you.

Apache access_log sample:
127.0.0.1 - - [22/Jun/2016:15:19:48 -0700] "GET /uri/sample/path HTTP/1.1" 200 20 15515

I created an extracted field called apachebytesize on the second column from the very right. In this example the number of bytes = 20. I change the search to the time frame that I want.

Sample Splunk search:
index=apache host=hostname sourcetype=accesslog | stats sum(apachebyte_size)

View solution in original post

Engager

Based on your answer, I created the following search that works in our load-balanced environment. Thank you!

source="/var/log/httpd/access_log" host="webprod-1.example.com" OR host="webprod-2.example.com" | stats sum(bytes)

0 Karma

Builder

what's the format of your logs? can you show some sample events with fields?

0 Karma

Engager

I think we are using the combined log format. In the sample entries below, empty fields are indicated by hyphens. The number of bytes sent to the client browser is indicated in the seventh field from the left. In the first sample, the value for bytes is 12. In the second sample, it is 8369.

10.107.88.13 - - [22/Jun/2016:03:43:24 -0500] "GET /" 200 12 "-" "-" - - - "-" "-" libweb-devel-cluster.example.com 80 SSL-off 2507 49683 -

68.180.229.190 - - [22/Jun/2016:04:22:49 -0500] "GET /tejanovoices/interview.php?cmasno=113 HTTP/1.1" 200 8369 "-" "Mozilla/5.0 (c
ompatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" - - - "-" "library.example.com" library.example.com 80 SSL-off 4447
1 44226 +

0 Karma