vozlt / nginx-module-vts

Nginx virtual host traffic status module
BSD 2-Clause "Simplified" License
3.17k stars 456 forks source link

nginx-module-vts version 0.1.8 in OpenResty 1.21.4.3 not display upstream data #296

Closed TSLIU2022 closed 3 weeks ago

TSLIU2022 commented 1 month ago

After compiling and installing nginx-module-vts version 0.1.8 in OpenResty 1.21.4.3, OpenResty starts without any errors. However, upon accessing the /status/format/json endpoint, the data within upstreamZones is found to be zero. Additionally, when querying the /status/format/prometheus endpoint, there are no entries related to upstreams present.

u5surf commented 1 month ago

@TSLIU2022 Hi, the version 0.1.8 is too old to use, can you use the latest one?

TSLIU2022 commented 1 month ago

Thank you for your response. I have implemented the latest nginx-module-vts version 0.2.2 and adjusted OpenResty 1.19.1 (corresponding to Nginx version 1.9.9, as indicated as tested in the documentation), yet the issue persists. The data from the upstream module via the /status/format/json endpoint remains problematic. Could you please assist me in debugging or adjusting the setup? Here is the relevant information for your reference.

image image
u5surf commented 1 month ago

@TSLIU2022

I have implemented the latest nginx-module-vts version 0.2.2 and adjusted OpenResty 1.19.1 (corresponding to Nginx version 1.9.9, as indicated as tested in the documentation), yet the issue persists.

Where can we find the description which we tested nginx version 1.9.9 or OpenResty 1.19.1? Moreover, we could not find any version OpenResty 1.19.1 in the official document of OpenResty.

https://openresty.org/en/changes.html

The latest version 1.25.3.1, the similar version you said is 1.19.3.x? Can you tell us the precise version? We cannnot investigate and reproduce anymore.

TSLIU2022 commented 1 month ago

I am referring to the information I saw regarding the tested Nginx versions for nginx-module-vts.

image

I downloaded the OpenResty version from the following link and here is a screenshot for reference. https://openresty.org/en/download.html

image

I have also tested OpenResty versions 1.25.3.1 and v1.21.4.3, encountering the same issue with each. My environment is running on ARM64 architecture, and OpenResty was installed via compilation.

SKDS commented 1 month ago

I came across a similar situation openresty/1.21.4.2 (old build dynamic module for nginx 1.21.4, show upstream data and cache), new build module only 0

Old build work openresty/1.21.4.3

Linux Rocky Linux 9 New build image_2024-05-27_06-02-25

image_2024-05-27_06-03-44 Old build image_2024-05-27_06-03-09

SKDS commented 1 month ago

I managed to overcome what seemed to be a problem, now I will describe my steps (I have a dynamic module)

My build machine: Linux: RL9 (5.14.0-162.18.1.el9_1.x86_64) Install openresty/1.21.4.3

wget https://openresty.org/download/openresty-1.25.3.1.tar.gz
tar -xzf  openresty-1.25.3.1.tar.gz
cd openresty-1.25.3.1/
export LUAJIT_LIB='/root/build/openresty-1.25.3.1/build/luajit-root/usr/local/openresty/luajit/lib'
export LUAJIT_INC='/root/build/openresty-1.25.3.1/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1'
./configure --with-compat --add-dynamic-module=../nginx-module-vts/
 make  -j 8

cp build/nginx-1.25.3/objs/ngx_http_vhost_traffic_status_module.so /etc/nginx/modules/ngx_http_vhost_traffic_status_module.so

image_2024-05-27_06-38-15

TSLIU2022 commented 1 month ago

@ SKDS Thank you for your suggestions and guidance; I will attempt to proceed with the dynamic compilation approach. Presently, I've encountered a scenario that seems to be related to the use of Lua scripts for HTTP request handling within OpenResty. However, I'm unable to pinpoint the exact issue at this moment. If nginx-module-vts could provide some form of logging or a debugging mechanism, it would greatly facilitate further troubleshooting and clarify the problem. Unfortunately, I haven't come across relevant documentation or resources for such functionality. Could you assist with this?

u5surf commented 1 month ago

@TSLIU2022 I could work fine the latest module with dynamic build in my environments.

version

sudo ./bin/openresty -V   
nginx version: openresty/1.21.4.3
built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 
built with OpenSSL 3.0.2 15 Mar 2022
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.2 --add-module=../echo-nginx-module-0.63 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.33 --add-module=../ngx_lua-0.10.25 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.34 --add-module=../array-var-nginx-module-0.06 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../rds-json-nginx-module-0.16 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.13 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-compat --add-dynamic-module=/home/u5surf/openresty-1.21.4.3/../nginx-module-vts --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module

nginx.conf


#user  nobody;                                
worker_processes  1;                        

load_module /usr/local/openresty/nginx/modules/ngx_http_vhost_traffic_status_module.so;

events {                    
    worker_connections  1024;                       
}      

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

    vhost_traffic_status_zone shared:vhost_traffic_status:32m;
    vhost_traffic_status_zone;
    proxy_cache_path /var/cache/nginx keys_zone=zone1:1m max_size=1g inactive=24h;

    upstream backend {
        zone backend 64k;
        server localhost:8080;
    }
    server {
        listen 8081;
        location / {
            proxy_cache zone1;
            proxy_pass http://backend;
            access_log /usr/local/nginx/logs/access.log;
        }
    }
    server {
        listen 8082;
        location /status {
            vhost_traffic_status_display;
            vhost_traffic_status_display_format html;
            vhost_traffic_status_bypass_stats on;
        }
    }
    server {
        root html;
        listen 8080;
        location / {
            index  index.html index.htm;
        }
    }
}

UI IMG_4093

Can you try the simplest way above this? Probably, using any else third party module (but I consider that it has no dependencies each other) or a particular case of nginx configuration might be encountered the case. We will investigate continuously.

TSLIU2022 commented 3 weeks ago

Thank you all for your support and assistance. I have managed to obtain upstream-related metrics by adopting dynamic compilation. Therefore, I am closing this issue now. Once again, thank you very much for your help.