0

I'm using an Nginx instance as load balancer for different location/endpoints (I am not tied to Nginx, so a different software load balancer (haproxy was suggested) would also be an option). Depending on the URL, the requests gets relayed to another ("backend") Nginx instance that handles the request or dispatches it further.

Is it possible retrieve stats about when the last request to a certain endpoint occurred and whether there's still an active connection to the handling backend server (websocket)? I looked at the ngx_http_stub_status_module, but the data one can get seems to be aggregated and not by backend server. The data should be processed programmatically, so I am not so much interested in charts, etc and I'd also like to avoid parsing log files, if possible (so perhaps connecting to a REST API or even a socket to get the monitor data would be great).

Anyway, any pointers are welcome.

orange
  • 101
  • 2
  • unfortunatly nginx has very limited stats in the load balancing section. if you really need them you should look to other options, like haproxy – Federico Galli Jun 19 '17 at 10:57
  • Good idea. I'm not really constrained by using Nginx (just did it out of habit). haproxy seems to have a socket interface which allows one to get those stats which is nice. Thanks for your suggestion! – orange Jun 20 '17 at 02:06
  • @FedericoGalli, do you have any idea how the last request to a backend with haproxy can be retrieved or whether it actually can be retrieved? I had a look at the configuration manual (https://www.haproxy.org/download/1.4/doc/configuration.txt, section 9.), but didn't see anything that provides this value directly or allows inference. – orange Jun 20 '17 at 02:20
  • i do have something like this but into the var/log haproxy.log: 163.xxx.68.xxx:40210 [20/Jun/2017:05:49:09.362] www-https https-backend/alpha 1/0/779 6556 -- 21/0/0/0/0 0/0 It's a normal log when the request is sent to a backend, is this valuable as "last" request? – Federico Galli Jun 20 '17 at 10:37
  • I would like to avoid parsing the logs. I could also have done this with Nginx... Upon studying more recent docs (https://www.haproxy.org/download/1.7/doc/management.txt), I came across a statistic called `conn_tot` which is the "cumulative number of connections". Keeping track of this value should allow for the detection of in/activity. – orange Jun 22 '17 at 00:34

0 Answers0