这里只是对prometheus监控Nginx的配置过程做个记录,方便以后查阅。
1.下载安装LuaJIT
1 | http://luajit.org/download.html |
2.下载ngx_devel_kit模块
1 | https://github.com/simplresty/ngx_devel_kit/releases |
3.下载lua-nginx模块
1 | https://github.com/openresty/lua-nginx-module/releases |
4.安装nginx依赖包zlib,pcre
1 | sudo yum -y install pcre-devel openssl openssl-devel |
5.下载安装nginx
1 | wget http://nginx.org/download/nginx-1.13.5.tar.gz |
安装nginx、nginx-lua 模块
1 | export LUAJIT_LIB=/usr/local/lib |
查看nginx模块,可能会报以下错误
1 | ./nginx/sbin/nginx -V |
解决方法
1 | sudo ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2 |
6.下载nginx-lua-prometheus
1 | wget https://github.com/knyar/nginx-lua-prometheus/archive/0.20181120.tar.gz |
7.nginx lua 配置
1 | #nginx monitor lua |
8.prometheus 拉取监控指标
1 | - job_name: 'wan' |
重启prometheus
如果开启了api管理功能,可以如下方式热加载配置
1 | curl -X POST http://127.0.0.1:9090/-/reload |
9.grafana出图
推荐使用9516
效果如下
上图监控面板我经过一些改动,仅供参考