Welcome! Log In Create A New Profile

Advanced

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

All files from this thread

File Name File Size   Posted by Date  
nginx.conf 1.9 KB open | download awani227 07/20/2021 Read message
Sergey A. Osokin
July 21, 2021 06:22AM
Hi Akki,

hope you're doing well these days.

On Tue, Jul 20, 2021 at 02:05:41PM +0530, awani227 wrote:
> 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' 

The $upstream_response_time embedded variable is available with
ngx_http_upstream module,
https://nginx.org/en/docs/http/ngx_http_upstream_module.html#variables

For ngx_stream_upstream you can utilize the following variables:
https://nginx.org/en/docs/stream/ngx_stream_upstream_module.html#variables

--
Sergey
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

awani227 July 20, 2021 04:36AM

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

Maxim Dounin July 20, 2021 08:38AM

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

Sergey A. Osokin July 21, 2021 06:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 291
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready