Skip to content

trockxi/nginx_lua_request_monitor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nginx_lua_request_monitor

nginx请求各项指标的监控与统计

主要功能

监控请求数、流量、请求时间、4xx、5xx等。

配置

http {
    include       mime.types;
    default_type  application/octet-stream;

    lua_shared_dict statistics_dict 50M;
    lua_package_path "your_path/nginx_lua_request_monitor/?.lua";

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        set $domain_monitor "site.test.xxx.com";
        log_by_lua_file "your_path/nginx_lua_request_monitor/reqstat.lua";

        location / {
            root   html;
            index  index.html index.htm;
        }
       
    }

    # 监控服务
    server {
        listen 6080;
        server_name localhost;
        location /nginx_status {
            content_by_lua_file "your_path/nginx_lua_request_monitor/status_api.lua";
        }
    }

}

提供的接口

Server Name key:test.xxx.com
Request Count:12
Request Time Sum:0
Flow Sum:5446
4xx Code Count:3
5xx Code Count:0 

扩展

如果有其他需求,比如监控location、upstream的监控,只需在相应配置的作用域块中加入变量即可,扩展很方便。

About

nginx请求各项指标监控

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%