kong.nginx
Nginx information module.
A set of functions for retrieving Nginx-specific implementation details and meta information.
kong.nginx.get_subsystem()
Returns the current Nginx subsystem this function is called from. Can be
one of "http"
or "stream"
.
Phases
- any
Returns
-
string
: Subsystem, either"http"
or"stream"
.
Usage
kong.nginx.get_subsystem() -- "http"
kong.nginx.get_statistics()
Returns various connection and request metrics exposed by Nginx, similar to those reported by the ngx_http_stub_status_module.
The following fields are included in the returned table:
-
connections_active
- the current number of active client connections includingconnections_waiting
. -
connections_reading
- the current number of connections where nginx is reading the request header. -
connections_writing
- the current number of connections where nginx is writing the response back to the client. -
connections_waiting
- the current number of idle client connections waiting for a request. -
connections_accepted
- the total number of accepted client connections. -
connections_handled
- the total number of handled connections. Same asconnections_accepted
unless some resource limits have been reached (for example, theworker_connections
limit). -
total_requests
- the total number of client requests.
Returns
-
table
: Nginx connections and requests statistics
Usage
local nginx_statistics = kong.nginx.get_statistics()