Send request and response logs to an HTTP server.
Configuration Reference
This plugin is compatible with requests with the following protocols:
http
https
grpc
grpcs
tcp
tls
udp
This plugin is compatible with DB-less mode.
In DB-less mode, Kong Gateway does not have an Admin API. If using this mode, configure the plugin using declarative configuration.
Enabling the plugin on a Service
<service>
is the id
or name
of the Service that this plugin
configuration will target.
Enabling the plugin on a Route
<route>
is the id
or name
of the Route that this plugin configuration
will target.
Enabling the plugin on a Consumer
<consumer>
is the id
or username
of the Consumer that this plugin
configuration will target.
Enabling the plugin globally
A plugin which is not associated to any Service, Route, or Consumer is considered global, and will be run on every request. Read the Plugin Reference and the Plugin Precedence sections for more information.
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
Form Parameter | Description |
---|---|
name
Type: string |
The name of the plugin to use, in this case http-log . |
service.id
Type: string |
The ID of the Service the plugin targets. |
route.id
Type: string |
The ID of the Route the plugin targets. |
consumer.id
Type: string |
The ID of the Consumer the plugin targets. |
enabled
Type: boolean Default value: true |
Whether this plugin will be applied. |
config.http_endpoint
required Type: string |
The HTTP URL endpoint (including the protocol to use) to which the data is sent. |
config.method
optional Type: string Default value: POST |
An optional method used to send data to the HTTP server. Supported values are
|
config.content_type
optional Type: string Default value: application/json |
Indicates the type of data sent. The only available option is |
config.timeout
optional Type: number Default value: 10000 |
An optional timeout in milliseconds when sending data to the upstream server. |
config.keepalive
optional Type: number Default value: 60000 |
An optional value in milliseconds that defines how long an idle connection will live before being closed. |
config.flush_timeout
optional Type: number Default value: 2 |
Optional time in seconds. If |
config.retry_count
optional Type: integer Default value: 10 |
Number of times to retry when sending data to the upstream server. |
config.queue_size
optional Type: integer Default value: 1 |
Max number of log entries to be sent on each message to the upstream server. |
config.headers
optional Type: array of string elements Default value: empty table |
An optional table of headers added to the HTTP message to the upstream server. The following
headers are not allowed: Note: This parameter is only available for versions 2.3.x and later. |
NOTE: If the config.http_endpoint
contains a username and password (for example,
http://bob:password@example.com/logs
), then Kong Gateway automatically includes
a basic-auth Authorization
header in the log requests.
Log Format
Every request is logged separately in a JSON object (or array of JSON objects if
queue_size
argument > 1) in the following format:
{
"request": {
"method": "GET",
"uri": "/get",
"url": "http://httpbin.org:8000/get",
"size": "75",
"querystring": {},
"headers": {
"accept": "*/*",
"host": "httpbin.org",
"user-agent": "curl/7.37.1"
},
"tls": {
"version": "TLSv1.2",
"cipher": "ECDHE-RSA-AES256-GCM-SHA384",
"supported_client_ciphers": "ECDHE-RSA-AES256-GCM-SHA384",
"client_verify": "NONE"
}
},
"upstream_uri": "/",
"response": {
"status": 200,
"size": "434",
"headers": {
"Content-Length": "197",
"via": "kong/0.3.0",
"Connection": "close",
"access-control-allow-credentials": "true",
"Content-Type": "application/json",
"server": "nginx",
"access-control-allow-origin": "*"
}
},
"tries": [
{
"state": "next",
"code": 502,
"ip": "127.0.0.1",
"port": 8000
},
{
"ip": "127.0.0.1",
"port": 8000
}
],
"authenticated_entity": {
"consumer_id": "80f74eef-31b8-45d5-c525-ae532297ea8e",
"id": "eaa330c0-4cff-47f5-c79e-b2e4f355207e"
},
"route": {
"created_at": 1521555129,
"hosts": null,
"id": "75818c5f-202d-4b82-a553-6a46e7c9a19e",
"methods": null,
"paths": [
"/example-path"
],
"preserve_host": false,
"protocols": [
"http",
"https"
],
"regex_priority": 0,
"service": {
"id": "0590139e-7481-466c-bcdf-929adcaaf804"
},
"strip_path": true,
"updated_at": 1521555129
},
"service": {
"connect_timeout": 60000,
"created_at": 1521554518,
"host": "example.com",
"id": "0590139e-7481-466c-bcdf-929adcaaf804",
"name": "myservice",
"path": "/",
"port": 80,
"protocol": "http",
"read_timeout": 60000,
"retries": 5,
"updated_at": 1521554518,
"write_timeout": 60000
},
"workspaces": [
{
"id":"b7cac81a-05dc-41f5-b6dc-b87e29b6c3a3",
"name": "default"
}
],
"consumer": {
"username": "demo",
"created_at": 1491847011000,
"id": "35b03bfc-7a5b-4a23-a594-aa350c585fa8"
},
"latencies": {
"proxy": 1430,
"kong": 9,
"request": 1921
},
"client_ip": "127.0.0.1",
"started_at": 1433209822425
}
A few considerations on the above JSON object:
request
contains properties about the request sent by the client.response
contains properties about the response sent to the client.tries
contains the list of tries and retries (successes and failures) made by the load balancer for the request.route
contains Kong Gateway properties about the specific Route requested.service
contains Kong Gateway properties about the Service associated with the requested Route.authenticated_entity
contains Kong Gateway properties about the authenticated credential if an authentication plugin has been enabled.workspaces
contains Kong Gateway properties of the Workspaces associated with the requested Route. Only in Kong Gateway version >= 0.34.consumer
contains the authenticated Consumer if an authentication plugin has been enabled.latencies
contains some data about the latencies involved:proxy
is the time it took for the final service to process the request.kong
is the internal Kong Gateway latency that it took to run all the plugins.request
is the time elapsed between the first bytes were read from the client and after the last bytes were sent to the client. Useful for detecting slow clients.
client_ip
contains the original client IP address.started_at
contains the UTC timestamp of when the request started to be processed.
Kong Gateway Process Errors
This logging plugin logs HTTP request and response data, and also supports streams data (TCP, TLS, and UDP).
If you are looking for the Kong process error file (which is the nginx error file), you can find it at the following path:
{prefix}/logs/error.log