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.
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 apache_byte_size 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=access_log | stats sum(apache_byte_size)
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 apache_byte_size 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=access_log | stats sum(apache_byte_size)
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)
what's the format of your logs? can you show some sample events with fields?
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 +