Home

Awesome

Mio

change NGINX world from metrics to insight

The first goal of Mio is to provide powerful API statistics and summary for NGINX.

Metrics is just base, the final goal is automatic improve the user's NGINX system with the power of data.

Dashborad screenshot

dashborad

Installation & run

install The latest OpenResty version.

If your OpenResty version above 1.11.2.1, pelase use develop branch instead of master branch. Because OpenResty added the optional "init" argument for shdict:incr() in 1.11.2.1, which can reduce a lot of if conditions and improve performance.

Please remember add --with-http_stub_status_module configuration parameter when run ./configure.

By default, OpenResty is installed into the prefix /usr/local/openresty/.


download Mio to your application directories, then run like this:

sudo openresty -p /opt/my-fancy-app/

If you build OpenResty from source code, maybe you can not find openresty,which is symbolic link to OpenResty's nginx executable file, /usr/local/openresty/nginx/sbin/nginx. So you can run like this:

sudo /usr/local/openresty/nginx/sbin/nginx -p /opt/my-fancy-app/

you can test Mio like this:

curl -i http://127.0.0.1/

hello! this is Mio.

curl -i http://127.0.0.1:9090/summary

{"/hello":{"total":1,"4xx":1,"sent":314,"request_time":0}}

curl -i http://127.0.0.1:9090/status

{"load_timestamp":1470384389,"requests":{"current":0,"total":2,"success":1},"worker_count":2,"address":"127.0.0.1:80","ngx_lua_version":"0.10.5","server_zones":[],"nginx_version":"1.9.15","connections":{"active":1,"writing":1,"current":1,"idle":0,"reading":0},"timestamp":1470384409,"generation":0,"upstreams":[]}

Open your browser with http://127.0.0.1:8080, you will you'll see a monitor page similar to NGINX plus. And this monitor page is preview version, we are working for it.


Congratulations,Mio is running!

If you run failed, please create a new issue, I will fix it ASAP.

TODO list

API Compatibility

The /status and /summary APIs are 100% compatible with NGINX Plus.

/status

curl http://127.0.0.1/status

NGINX Plus 的统计模块数据格式和说明文档在这里。NGINX Plus 的json 大块数据为:

{
    "version": 6,
    "nginx_version": "1.9.13",
    "address": "206.251.255.64",
    "generation": 21,
    "load_timestamp": 1462615200247,
    "timestamp": 1462870443024,
    "pid": 24978,
    "processes": {},
    "connections": {},
    "ssl": {},
    "requests": {},
    "server_zones": {},
    "upstreams": {},
    "caches": {},
    "stream": {}
}

注意下面数据的缩进,缩进代表json数据的组织

比如

代表的json格式为:

"server_zones":{
    "processing":0,
    "requests":71639,
    "responses":{
    	"1xx":0,
    	"2xx":66973,
    	"3xx":3289,
    	"4xx":941,
    	"5xx":264,
    	"total":71467
    },
    "discarded":172,
    "received":21575699,
    "sent":2652969417
},

/summary

出于性能考虑,summary 的统计数据会先放在 lru cache 中,由 timer 定时同步到 shared dict 中。 summary 接口的返回值格式为 json,示例:

day:{
    "/hello":{
        "total":123, -- 接口访问总数
        "avg_time":0.008, -- 平均返回时间
        "avg_size":10, -- 返回值的平均 body 大小
        "1xx":0,
        "2xx":100982,
        "3xx":0,
        "4xx":222,
        "5xx":112
    },
    "/status":{}
}