<p>I am running an nginx-ingress controller in a kubernetes cluster and one of my log statements for the request looks like this:</p>

<pre><code>upstream_response_length: 0, 840
upstream_response_time: 60.000, 0.760
upstream_status: 504, 200
</code></pre>

<p>I cannot quite understand what does that mean? Nginx has a response timeout equal to 60 seconds, and tries to request one more time after that (successfully) and logs both requests?</p>

<p>P.S. Config for log format:</p>

<pre><code>log-format-upstream: &gt;-
      {
      ...
      "upstream_status": "$upstream_status",
      "upstream_response_length": "$upstream_response_length",
      "upstream_response_time": "$upstream_response_time",
      ...
      }
</code></pre>

<p>According to <a href="https://github.com/kubernetes/ingress-nginx/blob/28793092e779f7cb66504a0e41db1fce2f93d91e/rootfs/etc/nginx/lua/util/split.lua#L24" rel="nofollow noreferrer"><code>split_upstream_var</code></a> method of <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">ingress-nginx</a>, it <a href="https://github.com/kubernetes/ingress-nginx/blob/f6c2f5fb974b496dbd58f3501df93aba226c708d/rootfs/etc/nginx/lua/balancer/sticky.lua#L75" rel="nofollow noreferrer">splits</a> results of <code>nginx</code> <a href="http://nginx.org/en/docs/http/ngx_http_upstream_hc_module.html" rel="nofollow noreferrer">health checks</a>.</p>

<p>Since <code>nginx</code> can have <a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html#example" rel="nofollow noreferrer">several upstreams</a>, your log could be  interpreted this way:</p>

<ol>
<li>First upstream is dead (504)</li>
</ol>

<pre><code>upstream_response_length: 0 // responce from dead upstream has zero length
upstream_response_time: 60.000 // nginx dropped connection after 60sec
upstream_status: 504 // responce code, upstream doesn't answer
</code></pre>

<ol start="2">
<li>Second upstream works (200)</li>
</ol>

<pre><code>upstream_response_length: 840 // healthy upstream returned 840b 
upstream_response_time: 0.760 // healthy upstream responced in 0.760
upstream_status: 200 // responce code, upstream is ok
</code></pre>

<p>P.S. JFYI, here's a cool HTTP headers state diagram</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/6/65/Http-headers-status.gif" alt="Http-headers-status"></p>
