# Nginx by HTTP ## Overview This template is developed to monitor Nginx by Zabbix that works without any external scripts. Most of the metrics are collected in one go, thanks to Zabbix bulk data collection. The template `Nginx by HTTP` - collects metrics by polling the [Module ngx_http_stub_status_module](https://nginx.ru/en/docs/http/ngx_http_stub_status_module.html) with HTTP agent remotely: ```text Active connections: 291 server accepts handled requests 16630948 16630948 31070465 Reading: 6 Writing: 179 Waiting: 106 ``` Note that this solution supports HTTPS and redirects. ## Requirements Zabbix version: 7.0 and higher. ## Tested versions This template has been tested on: - Nginx 1.17.2 ## Configuration > Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section. ## Setup See the setup instructions for [ngx_http_stub_status_module](https://nginx.ru/en/docs/http/ngx_http_stub_status_module.html). Test the availability of the `http_stub_status_module` with `nginx -V 2>&1 | grep -o with-http_stub_status_module`. Example configuration of Nginx: ```text location = /basic_status { stub_status; allow ; deny all; } ``` If you use another location, then don't forget to change the {$NGINX.STUB_STATUS.PATH} macro. Example answer from Nginx: ```text Active connections: 291 server accepts handled requests 16630948 16630948 31070465 Reading: 6 Writing: 179 Waiting: 106 ``` Note that this solution supports https and redirects. ### Macros used |Name|Description|Default| |----|-----------|-------| |{$NGINX.STUB_STATUS.SCHEME}|

The protocol http or https of Nginx stub_status host or container.

|`http`| |{$NGINX.STUB_STATUS.PATH}|

The path of the `Nginx stub_status` page.

|`basic_status`| |{$NGINX.STUB_STATUS.PORT}|

The port of the `Nginx stub_status` host or container.

|`80`| |{$NGINX.RESPONSE_TIME.MAX.WARN}|

The maximum response time of Nginx expressed in seconds for a trigger expression.

|`10`| |{$NGINX.DROP_RATE.MAX.WARN}|

The critical rate of the dropped connections for a trigger expression.

|`1`| ### Items |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Nginx: Get stub status page|

The following status information is provided:

`Active connections` - the current number of active client connections including waiting connections.

`Accepted` - the total number of accepted client connections.

`Handled` - the total number of handled connections. Generally, the parameter value is the same as for the accepted connections, unless some resource limits have been reached (for example, the `worker_connections` limit).

`Requests` - the total number of client requests.

`Reading` - the current number of connections where Nginx is reading the request header.

`Writing` - the current number of connections where Nginx is writing a response back to the client.

`Waiting` - the current number of idle client connections waiting for a request.

See also [Module ngx_http_stub_status_module](https://nginx.org/en/docs/http/ngx_http_stub_status_module.html).

|HTTP agent|nginx.get_stub_status| |Nginx: Service status||Simple check|net.tcp.service[http,"{HOST.CONN}","{$NGINX.STUB_STATUS.PORT}"]

**Preprocessing**

| |Nginx: Service response time||Simple check|net.tcp.service.perf[http,"{HOST.CONN}","{$NGINX.STUB_STATUS.PORT}"]| |Nginx: Requests total|

The total number of client requests.

|Dependent item|nginx.requests.total

**Preprocessing**

| |Nginx: Requests per second|

The total number of client requests.

|Dependent item|nginx.requests.total.rate

**Preprocessing**

| |Nginx: Connections accepted per second|

The total number of accepted client connections.

|Dependent item|nginx.connections.accepted.rate

**Preprocessing**

| |Nginx: Connections dropped per second|

The total number of dropped client connections.

|Dependent item|nginx.connections.dropped.rate

**Preprocessing**

| |Nginx: Connections handled per second|

The total number of handled connections. Generally, the parameter value is the same as for the accepted connections, unless some resource limits have been reached (for example, the `worker_connections limit`).

|Dependent item|nginx.connections.handled.rate

**Preprocessing**

| |Nginx: Connections active|

The current number of active client connections including waiting connections.

|Dependent item|nginx.connections.active

**Preprocessing**

| |Nginx: Connections reading|

The current number of connections where Nginx is reading the request header.

|Dependent item|nginx.connections.reading

**Preprocessing**

| |Nginx: Connections waiting|

The current number of idle client connections waiting for a request.

|Dependent item|nginx.connections.waiting

**Preprocessing**

| |Nginx: Connections writing|

The current number of connections where Nginx is writing a response back to the client.

|Dependent item|nginx.connections.writing

**Preprocessing**

| |Nginx: Version||Dependent item|nginx.version

**Preprocessing**

| ### Triggers |Name|Description|Expression|Severity|Dependencies and additional info| |----|-----------|----------|--------|--------------------------------| |Nginx: Failed to fetch stub status page|

Zabbix has not received any data for items for the last 30 minutes.

|`find(/Nginx by HTTP/nginx.get_stub_status,,"like","HTTP/1.1 200")=0 or nodata(/Nginx by HTTP/nginx.get_stub_status,30m)=1`|Warning|**Manual close**: Yes
**Depends on**:
| |Nginx: Service is down||`last(/Nginx by HTTP/net.tcp.service[http,"{HOST.CONN}","{$NGINX.STUB_STATUS.PORT}"])=0`|Average|**Manual close**: Yes| |Nginx: Service response time is too high||`min(/Nginx by HTTP/net.tcp.service.perf[http,"{HOST.CONN}","{$NGINX.STUB_STATUS.PORT}"],5m)>{$NGINX.RESPONSE_TIME.MAX.WARN}`|Warning|**Manual close**: Yes
**Depends on**:
| |Nginx: High connections drop rate|

The rate of dropping connections has been greater than {$NGINX.DROP_RATE.MAX.WARN} for the last 5 minutes.

|`min(/Nginx by HTTP/nginx.connections.dropped.rate,5m) > {$NGINX.DROP_RATE.MAX.WARN}`|Warning|**Depends on**:
| |Nginx: Version has changed|

The Nginx version has changed. Acknowledge to close the problem manually.

|`last(/Nginx by HTTP/nginx.version,#1)<>last(/Nginx by HTTP/nginx.version,#2) and length(last(/Nginx by HTTP/nginx.version))>0`|Info|**Manual close**: Yes| ## Feedback Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com) You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)