1.下载vts
cd /opt
git clone https://github.com/vozlt/nginx-module-vts.git
2.编译nginx
./configure --prefix=/app/nginx-1.22.1 \
--user=www \
--group=www \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--add-module=/opt/nginx-module-vts/
3.配置nginx加载vts模块
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;
}
}
4.访问状态页
5.配置prometheus
prometheus配置
job信息如下,保证 metrics_path写正确
- job_name: 'nginx'
metrics_path: /status/format/prometheus
static_configs:
- targets: ['192.168.xxx.xxx:80']
6.granafa-dashboard数据展示
导入9785面板