I'm looking for a way to be able to track the bandwidth of multiple vhosts on an nginx web server. I'm guessing there is a way that I can set up the log files to output this information and then I can write a script to parse through the log files and add up the file sizes.

If that is the case does anyone know the correct log format, and if there is already a script out there that does this?

2 Answers 2


You can define new logs and their format using ngx_http_log_module. You can use the following commands in http, server or location sections:

log_format name format [format ...] defines the format of the new log. Variable $bytes_sent will add the number of bytes sent for every request, including the length of HTTP headers.

access_log path [format [buffer=size]] specifies log-files. You can run this command for every vhost to define a separate log for every vhost.

  • Does this work with nginx-rtmp module?
    – Ben
    Feb 13, 2014 at 17:36
  • 1
    @Ben , I don't think so, sorry.
    – minaev
    Feb 27, 2014 at 7:03

There's a munin plugin that does exactly what you want - filters by specific vhosts and graphs it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .