Module ngx_http_status_module

ngx_http_status_module模块提供对各种状态信息的访问。

Note

在 1.13.10 之前,此模块是我们commercial subscription的一部分。在 1.13.3 中已被ngx_http_api_module模块取代。

Example Configuration

http {
    upstream backend {
        zone http_backend 64k;

        server backend1.example.com weight=5;
        server backend2.example.com;
    }

    proxy_cache_path /data/nginx/cache_backend keys_zone=cache_backend:10m;

    server {
        server_name backend.example.com;

        location / {
            proxy_pass  http://backend;
            proxy_cache cache_backend;

            health_check;
        }

        status_zone server_backend;
    }

    server {
        listen 127.0.0.1;

        location /upstream_conf {
            upstream_conf;
        }

        location /status {
            status;
        }

        location = /status.html {
        }
    }
}

stream {
    upstream backend {
        zone stream_backend 64k;

        server backend1.example.com:12345 weight=5;
        server backend2.example.com:12345;
    }

    server {
        listen      127.0.0.1:12345;
        proxy_pass  backend;
        status_zone server_backend;
        health_check;
    }
}

使用此配置的状态请求示例:

http://127.0.0.1/status
http://127.0.0.1/status/nginx_version
http://127.0.0.1/status/caches/cache_backend
http://127.0.0.1/status/upstreams
http://127.0.0.1/status/upstreams/backend
http://127.0.0.1/status/upstreams/backend/peers/1
http://127.0.0.1/status/upstreams/backend/peers/1/weight
http://127.0.0.1/status/stream
http://127.0.0.1/status/stream/upstreams
http://127.0.0.1/status/stream/upstreams/backend
http://127.0.0.1/status/stream/upstreams/backend/peers/1
http://127.0.0.1/status/stream/upstreams/backend/peers/1/weight

此发行版随附了简单的监视页面,在默认配置中,该页面可通过“ /status.html”访问。它要求如上所示配置位置“ /status”和“ /status.html”。

Directives

Syntax: status;
Default:
Context: location

可以从周围位置访问状态信息。可以访问此位置limited

Syntax: status_format json;

status_format jsonp [callback];
默认值: status_format json;
上下文: httpserverlocation

默认情况下,状态信息以 JSON 格式输出。

或者,数据可以作为 JSONP 输出。 callback参数指定回调函数的名称。参数值可以包含变量。如果省略参数,或者计算值是一个空字符串,则使用“ ngx_status_jsonp_callback”。

Syntax: status_zone zone;
Default:
Context: server

允许在指定的zone中收集虚拟httpstream(1.7.11)服务器状态信息。多个服务器可以共享同一区域。

Data

提供以下状态信息:

version

nginx_build

generation

load_timestamp

pid

ppid

processes

ssl

server_zones

discarded

 - The total number of requests completed without sending a response\.

slabs

upstreams

peers

 - For each [server](http-ngx_http_upstream_module.html#server), the following data are provided: 

id

   - The ID of the server\.

 - `server`

   - An [address](http-ngx_http_upstream_module.html#server) of the server\.

name

   - The name of the server specified in the [server](http-ngx_http_upstream_module.html#server) directive\.

service

   - The [service](http-ngx_http_upstream_module.html#service) parameter value of the [server](http-ngx_http_upstream_module.html#server) directive\.

 - `backup`

   - A boolean value indicating whether the server is a [backup](http-ngx_http_upstream_module.html#backup) server\.

 - `weight`

   - [Weight](http-ngx_http_upstream_module.html#weight) of the server\.

state

   - Current state, which may be one of "  `up` ", "  `draining` ", "  `down` ", "  `unavail` ", "  `checking` ", or "  `unhealthy` "\.

 - `active`

   - The current number of active connections\.

max_conns

   - The [max_conns](http-ngx_http_upstream_module.html#max_conns) limit for the server\.

 - `requests`

   - The total number of client requests forwarded to this server\.

 - `responses`

   - - `total`

     - The total number of responses obtained from this server\.

   - `1xx` ,  `2xx` ,  `3xx` ,  `4xx` ,  `5xx`

     - The number of responses with status codes 1xx, 2xx, 3xx, 4xx, and 5xx\.

 - `sent`

   - The total number of bytes sent to this server\.

 - `received`

   - The total number of bytes received from this server\.

 - `fails`

   - The total number of unsuccessful attempts to communicate with the server\.

 - `unavail`

   - How many times the server became unavailable for client requests \(state "  `unavail` "\) due to the number of unsuccessful attempts reaching the [max_fails](http-ngx_http_upstream_module.html#max_fails) threshold\.

 - `health_checks`

   - - `checks`

     - The total number of [health check](http-ngx_http_upstream_hc_module.html#health_check) requests made\.

   - `fails`

     - The number of failed health checks\.

   - `unhealthy`

     - How many times the server became unhealthy \(state "  `unhealthy` "\)\.

   - `last_passed`

     - Boolean indicating if the last health check request was successful and passed [tests](http-ngx_http_upstream_hc_module.html#match)\.

 - `downtime`

   - Total time the server was in the "  `unavail` ", "  `checking` ", and "  `unhealthy` " states\.

 - `downstart`

   - The time \(in milliseconds since Epoch\) when the server became "  `unavail` ", "  `checking` ", or "  `unhealthy` "\.

selected

   - The time \(in milliseconds since Epoch\) when the server was last selected to process a request \(1\.7\.5\)\.

header_time

   - The average time to get the [response header](http-ngx_http_upstream_module.html#var_upstream_header_time) from the server \(1\.7\.10\)\. Prior to version 1\.11\.6, the field was available only when using the [least_time](http-ngx_http_upstream_module.html#least_time) load balancing method\.

response_time

   - The average time to get the [full response](http-ngx_http_upstream_module.html#var_upstream_response_time) from the server \(1\.7\.10\)\. Prior to version 1\.11\.6, the field was available only when using the [least_time](http-ngx_http_upstream_module.html#least_time) load balancing method\.

zombies

 - The current number of servers removed from the group but still processing active client requests\.

zone

 - The name of the shared memory [zone](http-ngx_http_upstream_module.html#zone) that keeps the group's configuration and run\-time state\.

queue

 - For the requests [queue](http-ngx_http_upstream_module.html#queue), the following data are provided: 

max_size

   - The maximum number of requests that can be in the queue at the same time\.

 - `overflows`

   - The total number of requests rejected due to the queue overflow\.

caches

stream

sessions

   - - `total`

     - The total number of completed client sessions\.

   - `2xx` ,  `4xx` ,  `5xx`

     - The number of sessions completed with [status codes](stream-ngx_stream_core_module.html#var_status) 2xx, 4xx, or 5xx\.

discarded

   - The total number of connections completed without creating a session\.

 - `received`

   - The total number of bytes received from clients\.

 - `sent`

   - The total number of bytes sent to clients\.

upstreams

 - For each [dynamically configurable](stream-ngx_stream_upstream_module.html#zone) [group](stream-ngx_stream_upstream_module.html#upstream), the following data are provided: 

name

     - The name of the server specified in the [server](stream-ngx_stream_upstream_module.html#server) directive\.

service

     - The [service](stream-ngx_stream_upstream_module.html#service) parameter value of the [server](stream-ngx_stream_upstream_module.html#server) directive\.

   - `backup`

     - A boolean value indicating whether the server is a [backup](stream-ngx_stream_upstream_module.html#backup) server\.

   - `weight`

     - [Weight](stream-ngx_stream_upstream_module.html#weight) of the server\.

   - `state`

     - Current state, which may be one of "  `up` ", "  `down` ", "  `unavail` ", "  `checking` ", or "  `unhealthy` "\.

   - `active`

     - The current number of connections\.

   - `max_conns`

     - The [max_conns](stream-ngx_stream_upstream_module.html#max_conns) limit for the server\.

   - `connections`

     - The total number of client connections forwarded to this server\.

   - `connect_time`

     - The average time to connect to the upstream server\. Prior to version 1\.11\.6, the field was available only when using the [least_time](stream-ngx_stream_upstream_module.html#least_time) load balancing method\.

   - `first_byte_time`

     - The average time to receive the first byte of data\. Prior to version 1\.11\.6, the field was available only when using the [least_time](stream-ngx_stream_upstream_module.html#least_time) load balancing method\.

   - `response_time`

     - The average time to receive the last byte of data\. Prior to version 1\.11\.6, the field was available only when using the [least_time](stream-ngx_stream_upstream_module.html#least_time) load balancing method\.

   - `sent`

     - The total number of bytes sent to this server\.

   - `received`

     - The total number of bytes received from this server\.

   - `fails`

     - The total number of unsuccessful attempts to communicate with the server\.

   - `unavail`

     - How many times the server became unavailable for client connections \(state "  `unavail` "\) due to the number of unsuccessful attempts reaching the [max_fails](stream-ngx_stream_upstream_module.html#max_fails) threshold\.

   - `health_checks`

     - - `checks`

       - The total number of [health check](stream-ngx_stream_upstream_hc_module.html#health_check) requests made\.

     - `fails`

       - The number of failed health checks\.

     - `unhealthy`

       - How many times the server became unhealthy \(state "  `unhealthy` "\)\.

     - `last_passed`

       - Boolean indicating if the last health check request was successful and passed [tests](stream-ngx_stream_upstream_hc_module.html#match)\.

   - `downtime`

     - Total time the server was in the "  `unavail` ", "  `checking` ", and "  `unhealthy` " states\.

   - `downstart`

     - The time \(in milliseconds since Epoch\) when the server became "  `unavail` ", "  `checking` ", or "  `unhealthy` "\.

   - `selected`

     - The time \(in milliseconds since Epoch\) when the server was last selected to process a connection\.

 - `zombies`

   - The current number of servers removed from the group but still processing active client connections\.

 - `zone`

   - The name of the shared memory [zone](stream-ngx_stream_upstream_module.html#zone) that keeps the group's configuration and run\-time state\.

Compatibility

首页