HA-Proxy日志的含义

Meaning of HA-Proxy log

在 HA-Proxy 中获取以下日志,但它没有命中我的 spring-boot 应用程序的控制器方法。而且它也没有提到 http 状态代码。但其他请求有 http 状态代码。

Nov 4 11:56:31 localhost haproxy[24972]: 112.134.131.29:17817 [04/Nov/2021:11:56:31.862] myservice k8-sit-masters/k8-master-2 0/0/0/-1/0 -1 0 - - SD--           2/2/0/0/0 0/0 "POST /path/to/my/url HTTP/1.1"

知道这个日志是什么意思。

Nov 4 11:56:31             => Log Time Stamp
localhost                  => Hostname or IP address of HAProxy host
haproxy[24972]             => Process ID for the HAProxy process
112.134.131.29:17817       => Source IP:Source Port
[04/Nov/2021:11:56:31.862] => Request Accepted timestamp
myservice                  => Front-end name
k8-sit-masters/k8-master   => Target request was routed to
0/0/0/-1/0                 => Time waiting for full request from client (ms) / Time waiting in queues (ms) / Time to establish connection to destination server (ms) / Time for destination server to send response (ms) / Total time request active in HAProxy (ms)
-1                         => http status
 0                         => bytes read
 - -                       => Pptional values (captured request cookie, captured response cookie)
 SD--                      => Termination state, cookie status
 2/2/0/0/0                 => Active connections / Front-end connections / Back-end connections / Server connections / Retries
 0/0                       => Server queue size / Back-end queue size
 "POST /path/to/my/url HTTP/1.1" => Request method, API URL, http version

参考:HAProxy Log definition

正如我们在日志中看到的 http 状态代码是 -1。 -1 表示状态代码不可用。原因在终止标志字段中。在你的情况下 termination flag 值是 SD。这里

S => the TCP session was unexpectedly aborted by the server, or the
        server explicitly refused it.
D => the session was killed by haproxy because the server was detected
        as down and was configured to kill all connections when going down.