Welcome! Log In Create A New Profile


counters in nginx

Roman Vasilyev
February 09, 2011 09:10PM

I need to realize event counters in nginx.
So I've planned to create command like "counter".
And have something similar to HttpLimit(Zone/Req)Module,
so my config should looks like:
http {
counter_zone one $binary_remote_addr 10m;
server {
location / {
count one $my_event; #( $my_event can be 0 or 1 )
and have extra location like
location /my_one_stats { # will give stats to external script for
specific argument;
counter_handler one $args_one;

location /my_one_stats_reset { # will reset stats for specific argument;
counter_reset one $args_one;

In this case to be insured that my counter working in final phase I have
to register this handler in NGX_HTTP_LOG_PHASE phase, otherwise I
wouldn't know for sure that event is done.
But if I'll register it on init like:
h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers);
my handler will be called after HttpLogModule, so if I'll try to log
counter only previous value will be logged.

So my question:
1) May be exists more effective way to realize it, or it already realized?
2) What the best way to register handler before HttpLogModule but in


nginx mailing list
Subject Author Posted

counters in nginx

Roman Vasilyev February 09, 2011 09:10PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 61
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready