What does http-log kong latency include?

We are using http-log plugin to log all our requests through a http server. The upstream server for logging is an aws lambda function. Its very confusing to understand from the documentation what does the field “latencies.kong” consider to compute the latency? From the documentation ,

kong is the internal Kong latency that it took to run all the plugins.

Does it include the http-log latency itself ? (which is not possible is my understanding).

Can some one please clarify?

Also, if the kong latency is high even though the proxy latency is low, how should I go about debugging the issue ?

latencies.kong is collected here. KONG_PROXY_LATENCY is collected throughout the Kong runloop as appropriate, and KONG_RECEIVE_TIME is non-zero if Kong had to spend time collecting the body for a body_filter phase plugin. These latencies won’t include the latency of http-log itself since the log phase is run after the response to sent to the client, so the log phase’s performance isn’t part of the math of how long a request took.

As for debugging the issue, Kong provides a number of other variables in the context, including when various phases begin and end, here. Identifying the largest discrepencies in start and end timing can help pinpoint the source, as can removing and re-adding plugins. Typically performance problems stemming from high latencies.kong are going to be caused by plugins but, in the event that they aren’t, tools such as openresty-systemtap-toolkit may help pinpoint where you’re running into trouble.

Hi, Thanks for the insights :slight_smile: I wanted to analyze the other variables in the kong.ctx. And i was trying out the custom_fields_by_lua configuration of the http-log plugin to log the values of the fields. But I ended up in an error

'custom_fields_by_lua': unknown field

Am i missing something here ? I have also set the kong configuration

untrusted_lua=sandbox

Here is how my http-log declarative configuration looks like:

plugins:
  - name: http-log
    route: status
    config:
      http_endpoint: http://localhost:5000/logs
      method: POST
    custom_fields_by_lua:
      - debug_logs: "return kong.ctx"

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ