Question about traffic statistics on each vhost,is it possible?

largest $bytes_sent i seem to be getting is 83,802 bytes…

also, i want to log both inbound and outbound http traffic - file
uploads, etc… is there a combination of $bytes_sent i need + another
variable etc? to be able to track all the bytes in and out of nginx
and relate it to a host: header (if one exists)

p.s. i also have a LOT of 0 byte $bytes_sent too

This is what I have right now (set on a global http {} level)

log_format traffic ‘$http_host|$bytes_sent|$time_local|$remote_addr’;
access_log /var/log/nginx/traffic traffic;

Problem is, I don’t seem to be getting large requests - or am I, but
the requests are split up into buffers and logged as such? So one 1MB
file might show up 8x in the log if each 128k was logged separately?

Hi mike,

I see plenty MegaBits showing up in my logs so there is no problem
logging big files, there is probably a problem somewhere in your
config file? Note that the bytes_sent are only recorded when the
connection closes, so for a big file it will take some time before it
appears in the log file.

I do get a lot of 0 bytes too, I think it is because when a browser
receives an html page, it has all sorts of links to css files and
pictures, if these files are in the browser cache, it will issue a
request but won’t actually download the file. I know my explanation is
stupid, but it’s the only things I could come up with.

Hello!

On Wed, Oct 08, 2008 at 11:59:45AM -0700, mike wrote:

[…]

Followup question: is $bytes_sent the only variable I need? Or do I
need something like $bytes_received or $total_request / $request_size
or anything else to get -all- traffic both ways?

Currently there is no way to log bytes received from client. This
was discussed some time ago on russian mailing lists though, and
simple patch for this was mentioned by Boris D… Here is his
message:

http://article.gmane.org/gmane.comp.web.nginx.russian/19189

Maxim D.

Well I don’t know Russian but I’d like to formally request this be
included into the latest 7.x version at anyone’s convenience :slight_smile:

Nope -

Maybe I was quick to judge this. The first 600,000 records did not
show me anything large, however now I am seeing 412mb, 228, lots of
150’s etc. That works.

Followup question: is $bytes_sent the only variable I need? Or do I
need something like $bytes_received or $total_request / $request_size
or anything else to get -all- traffic both ways?

| 412405209 |
| 228866862 |
| 191663012 |
| 177851240 |
| 175002878 |
| 161074742 |
| 152268762 |
| 152268762 |
| 152268762 |
| 152268762 |
| 152268762 |
| 152268762 |
| 152268762 |
| 152268762 |
| 152268748 |
| 152268748 |
| 152268748 |
| 152268748 |
| 152268748 |
| 152268748 |