vozlt / nginx-module-vts

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

Question about nginx_vts_upstream_requests_total metric #266

Open franciscocpg opened 1 year ago

franciscocpg commented 1 year ago

I was using the error_page directive with a static page serving the 5xx errors (see the snippet below) and when the backend upstream returned a 5xx http code, I was seeing something like this in the metrics:

nginx_vts_upstream_requests_total{upstream="backend-service-1",backend="1.2.3.4:80",code="5xx"} 1
nginx_vts_upstream_requests_total{upstream="backend-service-2",backend="5.6.7.8:80",code="5xx"} 1

static page serving the 5xx errors config

error_page 500 501 502 503 504 /error/5xx.html;

location ^~ /error/ {
  root /usr/share/nginx/html;
}

Then I changed the config to use an upstream to serve the error pages instead of a static page, eg: upstream serving the 5xx errors config

error_page 500 501 502 503 504 /error-pages/500;

location /error-pages/500 {
  proxy_pass http://web-error-pages/500;
}

And now when my backend upstream returns a 5xx http code I see the following in the metrics:

nginx_vts_upstream_requests_total{upstream="web-error-pages",backend="1.2.3.4:80",code="5xx"} 2

So I lost track of which origin upstream is returning the error since the metrics are being aggregated in the web-error-pages upstream.

Is there a way to make this change keeping track of which origin upstream is returning a 5xx error code?

u5surf commented 1 year ago

@franciscocpg Hi,Thanks. Could you tell me what is the detail of backend-service-1 and backend-service-2 before you change the static pages config? We cannot see the both of upstream at all. It is necessary to figure out what happened.

After you changed to use web-error-pages, it seems to work completely fine because all the request arrived at the location of the /error-pages/500 can be proxied for the upstream of the web-error-page.