Can i collect stats without modifying nginx core code?

I’m trying to write a module that will collect extended stats, that is
more then what is offered by stub_status. I’ve dumped a couple of stats,
but had to modify source code outside the module. Modifying vanilla
source isn’t an option for me. So before I begin, I was wondering if I
could get some information:

  1. Can I collect stats on every request? I want to know how many bytes
    were written in the body and headers out to the client.
  2. Is it possible to collect stats on reverse proxy’s? IE: how many
    upstream connections are there, have there been, failed, 50x’s?
  3. Do this all inside of a module?

Thanks in advance.

Posted at Nginx Forum: