Skip to content

Commit

Permalink
feat(core) add X-Kong-Upstream-Status header
Browse files Browse the repository at this point in the history
While Kong returns the same status code as
that of the upstream when it proxies a request,
it is useful to record the real status code
returned by the upstream.

This can be used for monitoring Kong
itself if it is returning the same response
as the upstream.
  • Loading branch information
hbagdi committed Feb 26, 2018
1 parent 637532e commit f36e5c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions kong/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ return {
HOST_OVERRIDE = "X-Host-Override",
PROXY_LATENCY = "X-Kong-Proxy-Latency",
UPSTREAM_LATENCY = "X-Kong-Upstream-Latency",
UPSTREAM_STATUS = "X-Kong-Upstream-Status",
CONSUMER_ID = "X-Consumer-ID",
CONSUMER_CUSTOM_ID = "X-Consumer-Custom-ID",
CONSUMER_USERNAME = "X-Consumer-Username",
Expand Down
1 change: 1 addition & 0 deletions kong/core/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ return {
local now = get_now()
ctx.KONG_WAITING_TIME = now - ctx.KONG_ACCESS_ENDED_AT -- time spent waiting for a response from upstream
ctx.KONG_HEADER_FILTER_STARTED_AT = now
header[constants.HEADERS.UPSTREAM_STATUS] = ngx.status
end
end,
after = function(ctx)
Expand Down

0 comments on commit f36e5c8

Please sign in to comment.