0

I have an nginx loadbalancer which just proxies requests to a few upstream servers.

Now, what I would like to do is:

For one out of ten requests, I want to measure the response time of nginx (in milliseconds) and forward that value to an InfluxDB metric database.

I'm not sure how I can make this work. My initial idea was to leverage the "access_by_lua_block" functionality, but if I understand correctly, this is executed before the request is sent to the upstream server. Is there a way to execute lua-code after a response is received from the upstream server?

Just to be clear: I want to the response time of the nginx loadbalancer itself, not of the upstream application server. My final goal is to compare the response times of the loadbalancer with the response times of the upstream servers, to identify potential bottlenecks in the loadbalancer configuration.

0

As you are undecided about the Lua route, did you consider New Relic with the Nginx plugin? Especially with Nginx Plus, you can get a lot of what you are after: https://newrelic.com/plugins/nginx-inc/13

Datadog has similar functionality, and logs load balancer performance explicitly: https://www.datadoghq.com/blog/monitor-nginx-plus-load-balancing-metrics/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.