Need some guidance for setting upstream logs in NGINX TCP Load Balancer

awani227 awani227 at zohomail.in
Tue Jul 20 08:35:41 UTC 2021


Hi,



I'm using 'nginx/1.21.1' for load balancing TCP connection for DBs like Teradata, Netezza, Oracle and MySQL. I'm using stream directive for it as per the guidance 'https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/' . 



Following is my stream configuration  (/etc/nginx/nginx.conf)

stream {

    log_format  timed_combined  '$remote_addr - [$time_local] $session_time $msec $status $protocol ua="$upstream_addr" "$upstream_connect_time" "$upstream_response_time"';

    access_log /var/log/nginx/access.log timed_combined;

  

    upstream stream_backend_mysql {

        hash $remote_addr;

        server 192.168.122.251:3306;

        server 192.168.122.252:3306;

    }

    server {

        listen 3306;

        proxy_pass stream_backend_mysql;

        proxy_connect_timeout 1s;

    }

}



I'm able to establish connection for mysql in this setup, but when I'm adding the log_format directive nginx is giving following error,

'nginx: [emerg] unknown "upstream_response_time" variable' 



My motive is to get metrics for this nginx tcp loadbalancer (like requests per seconds, number of active connections).



Please guide me on this as I'm a newbie in this field.



I'm attaching my nginx.conf for your reference with this mail. 



Looking forward for your response.



Thank you in anticipation!



Regards,

Akki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20210720/aac08fa2/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx.conf
Type: application/octet-stream
Size: 1990 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20210720/aac08fa2/attachment.obj>


More information about the nginx mailing list