查看nginx编译安装时安装了哪些模块
[root@nginx1 sbin]# ./nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module
加入需要安装的模块,重新编译,如这里添加–add-module=/root/mapr/nginx-module-vts
[root@nginx1 nginx]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --add-module=/root/mapr/nginx-module-vts
make编译 不要make install, 不然会覆盖
替换nginx二进制文件
[root@nginx1 nginx]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak20180330
[root@nginx1 nginx]# cp ./objs/nginx /usr/local/nginx/sbin/
修改Nginx配置
http {
...
vhost_traffic_status_zone;
#vhost_traffic_status_filter_by_host on;
...
server {
...
location /status {
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
}
}
验证nginx-module-vts模块
访问http://IP/status,出现数据页面
安装nginx-vts-exporter
下载解压 exporter
chmod +x /usr/local/prometheus/nginx-vts-exporter/bin/nginx-vts-exporter
启动exporter
./nginx-vts-exporter -nginx.scrape_uri=http://localhost/status/format/json
修改prometheus.yml,加入下面的监控目标:
nginx-vts-exporter默认的抓取地址为http://IP:9913/metrics