[PYTHON] [blackbird-nginx] Monitor Nginx with blackbird

blackbird nginx plugin

This plugin gets various information from nginx and sends the data to backend Currently, you can monitor the following information:

Install

blackbird body

Please install by referring to here

Install nginx plugin

You can either use setup.py or rpm. You can also insert it manually, but in that case, please use the module of requests of python separately.

install with setup.py

git clone https://github.com/Vagrants/blackbird-nginx.git
cd blackbird-nginx
python setup.py install

install with rpm

yum install blackbird-nginx--enablerepo=blackbird

Dependencies require python-requests

Allow status to be taken on the Nginx side

Define stub_status

pl:/etc/nginx/conf.d/stub_status.conf


server {
    listen 80;
    server_name localhost;
    location /nginx_status {
        stub_status on;
        access_log  off;
        allow 127.0.0.1;
        deny  all;
    }
}

For example, like this

Set plugin

config is in /etc/blackbird/conf.d/nginx.cfg

ini:/etc/blackbird/conf.d/nginx.cfg


[nginx]
module = 'nginx'

# stub_status URI
# - support only http status code '200'
# - you must set uri value start with '/'
#
status_uri = '/nginx_status'
# host = '127.0.0.1'
# port = '80'

# use ssl connection?
#
# ssl = False

# for BASIC authentication. default: Nothing
#
# user = 'nobody'

# for BASIC authentication. default: Nothing
#
# password = 'nobody'

# for response time check
# if you do not want to check, please comment out
# - support only http status code '200'
# - you must set uri value start with '/'
#
response_check_uri = '/'
# response_check_port = '80'
# response_check_host = '127.0.0.1'
# response_check_vhost = 'localhost'
# response_check_uagent = 'blackbird response check'
# response_check_ssl = False

# nginx path
path = '/usr/sbin/nginx'

If response_check_uri is specified, HTTP GET to that uri Measure HTTP status code and Response Time By also setting the virtual host, it is possible to monitor the response of the virtual host for service use.

Reboot blackbird when you're done

sudo /etc/init.d/blackbird restart

Check if data is coming in on Zabbix

Zabbix Template can be found in github repository Please import to Zabbix and apply to the target server

** If the host name on Zabbix and the host name of the server on which blackbird is running are different, you need to set the hostname on /etc/blackbird/conf.d/nginx.cfg ** Please match with Zabbix

ini:/etc/blackbird/conf.d/nginx.cfg


hostname = your_static_hostname

You can also change the monitoring interval (default 60 seconds)

ini:/etc/blackbird/conf.d/nginx.cfg


interval = 30

About Zabbix Template items

_Nginx_1.4

Application item description
Nginx - Stats Stats - Accepts stub_status Accepts
Nginx - Stats Stats - Accepts cps Connection Per Sec above
Nginx - Stats Stats - Handled stub_status Handled
Nginx - Stats Stats - Handled cps Connection Per Sec above
Nginx - Stats Stats - Requests stub_status Requests
Nginx - Stats Stats - Requests cps Connection Per Sec above
Nginx - Stats Stats - Reading stub_status Reading
Nginx - Stats Stats - Writing stub_status Writing
Nginx - Stats Stats - Waiting stub_status Waiting
Nginx - Performance Performance - Amount item for aggregate
Nginx - Performance Performance - Available item for aggregate
Nginx - Performance Performance - Response status response_check_uriHTTP status
Nginx - Performance Performance - Response Time response_check_uriResponse Time
Version Version - Nginx nginx version
General General - Blackbird nginx plugin is sending data Ping from blackbird
General General - Blackbird nginx plugin version version of nginx plugin
General General - Port $PORT is in LISTENING state Is a specific port listening?
General General - Port $PORT is accepting connections Whether the specific port accepts
General Process - Number of nginx processes nginx process number
Macro {$ITM_NGINX_MONITOR_URI} For item display(nginx.Please match with cfg)
Macro {$ITM_NGINX_MONITOR_VHOST} For item display(nginx.Please match with cfg)
Macro {$ITM_NGINX_PORT} nginx port
Macro {$TRG_BBD_NGX_NDT_PRD} Ping interval threshold from blackbird
Macro {$TRG_NGINX_RSP_TIME} Response Time threshold
About {$ TRG_BBD_NGX_NDT_PRD}

Raises a Trigger if the ping item is not updated at regular intervals to detect that the blackbird is down. The threshold of that interval If you lengthened the interval in /etc/blackbird/conf.d/nginx.cfg, increase this value as well.

About {$ TRG_NGINX_RSP_TIME}

Trigger goes up when Response Time is greater than a certain number of seconds Will be that threshold (In Template, Trigger is raised when the threshold is exceeded 3 times in a row, but change it according to the environment.)

The template name is \ _Nginx_1.4, but it can also be used in 1.6 series.

_Nginx_group_monitor

Application item description
Nginx - Group Group - Total servers Total number of group monitoring servers
Nginx - Group Group - Available servers Healthy number of group monitoring servers
Nginx - Group Group - Available servers rate That percentage
Macro {$ITM_NGINX_GROUP_NAME} group Monitor host group
Macro {$TRG_NGINX_AVAILABLE_RATE} Trigger threshold

This \ _Nginx_group_monitor is supposed to be used when you want to know how many normal servers are in the server group under load balancer. For example, you can detect that half of the servers that are load balanced with 10 are returning anything other than HTTP status 200. Since Zabbix's Aggregate function is used, the servers you want to monitor must be grouped together in the same host group. By the way, the server to which this Template is applied can be honestly anywhere (127.0.0.1 etc.), but as an easy-to-understand method, if you define the host of vip for load balance on Zabbix and apply it to that host. Okay

Recommended Posts

[blackbird-nginx] Monitor Nginx with blackbird
[blackbird-rabbitmq] Monitor rabbitmq with blackbird
[blackbird-aerospike] Monitor Aerospike with blackbird
[blackbird-xfs] Monitor xfs with blackbird
[blackbird-mysql] Monitor mysql with blackbird
[blackbird-memcached] Monitor Memcached with blackbird
[blackbird-fio-status] Monitor ioDrive (Fusion-IO) with blackbird
[blackbird-named] Monitor Bind (named) with blackbird
[blackbird-ntp] Monitor ntpq information (offset, jitter, etc.) with blackbird
API with Flask + uWSGI + Nginx
Control error wording with nginx
Monitor Tomcat process with Zabbix-agent
Build FastAPI + uvicorn + nginx with docker-compose
Monitor Python web apps with Prometheus
Monitor Python application performance with Dynatrace ♪
Monitor ISC DHCP status with ZABBIX