Nginx系列之5:监控
开启监控模块
配置访问地址
location /nginxstatus { stub_status on; // 禁止将监控信息写入访问日志 access_log off; }
激活插件http_stub_status_module
cd /usr/local/src/nginx-1.18.0 # 如果不是使用的默认路径,使用 --prefix 指定 ./configure --with-http_stub_status_module make && make install /usr/local/nginx/sbin/nginx -s quit /usr/local/nginx/sbin/nginx
访问地址http://192.168.10.11:8080/nginxstatus,
Active connections: 2 server accepts handled requests 14 14 78 Reading: 0 Writing: 1 Waiting: 1
状态参数如下
- Active connections:活跃的连接数量
- server accepts handled requests:处理的总连接数 创建的握手数 处理的总请求数
- reading:读取客户端的Header信息的次数。这个操作仅读取头部信息,完成后立即进入writing状态
- writing:响应数据传到客户端的Header信息次数。这个操作不仅读取头部,还要等待服务响应
- waiting:开启keep-alive后等候下一次请求指令的驻留连接
Logtail数据采集图表展示
安装Logtail。
安装logtail,确认版本号在0.16.0及以上。若低于0.16.0版本请根据文档提示升级到最新版本。
填写采集配置。
样例配置如下
{ "inputs": [ { "type": "metric_http", "detail": { "IntervalMs": 60000, "Addresses": [ "http://10.10.XX.XX/private/nginx_status", "http://10.10.XX.XX/private/nginx_status", "http://10.10.XX.XX/private/nginx_status" ], "IncludeBody": true } } ], "processors": [ { "type": "processor_regex", "detail": { "SourceKey": "content", "Regex": "Active connections: (\\d+)\\s+server accepts handled requests\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+Reading: (\\d+) Writing: (\\d+) Waiting: (\\d+)[\\s\\S]*", "Keys": [ "connection", "accepts", "handled", "requests", "reading", "writing", "waiting" ], "FullMatch": true, "NoKeyError": true, "NoMatchError": true, "KeepSource": false } } ] }
图表
Logtail详细见阿里云官网:
https://help.aliyun.com/document_detail/65673.html
也可以使用其他开源比如logstash来采集日志。可参考:
相关推荐
nginxs 2020-11-14
Guanjs0 2020-11-13
小木兮子 2020-11-11
yserver 2020-11-11
ssihc0 2020-11-11
windle 2020-11-10
HanksWang 2020-11-10
liuchen0 2020-11-10
Freshairx 2020-11-10
ccschan 2020-11-10
liwf 2020-11-10
Guanjs0 2020-11-09
AderStep 2020-11-09
zrtlin 2020-11-09
mqfcu 2020-11-10
windle 2020-10-29