将请求和响应数据附加到磁盘上的日志文件中。
不建议再生产中使用此插件,最好使用其它日志插件
此插件具有以下协议的请求兼容:
http
https
Grpc
Grpcs
此插件与无DB模式兼容
名称 | 描述 |
---|---|
ame | 要使用插件的名称 file-log |
Service_id | 将定位的服务ID |
Route_id | 将定位的路由 |
Enabled | 是否将应用此插件,默认值true |
Consumer_id | .此插件将定位的Consumer的id |
Config.path: | 输出日志文件的文件路径。如果该文件尚不存在,该插 件将创建该文件。确保Kong对此文件具有写入权限 |
{
"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
}
request
包含有关客户端发送的请求的属性
response
包含有关发送到客户端的响应的属性
tries
包含负载均衡器为此请求进行的(重新)尝试(成功和失败)列表
route
包含有关所请求的特定路线的Kong属性
service
包含与所请求的路线相关联的服务的Kong属性
authenticated_entity
包含有关经过身份验证的凭据的Kong属性(如果已启用身份验证插件)
workspaces
包含与请求的路由关联的工作空间的Kong属性。仅限Kong Enterprise版本> = 0.34。
consumer
包含经过身份验证的使用者(如果已启用身份验证插件)
latencies:
包含一些有关延迟的数据:
proxy
是最终服务处理请求所花费的时间kong
是运行所有插件所需的内部Kong延迟request
是从客户端读取的第一个字节之间以及最后一个字节发送到客户端之间经过的时间。用于检测慢速客户端。client_ip
包含原始客户端IP地址
started_at
包含开始处理请求的UTC时间戳。
将请求和响应日志发送到HTTP服务器。
此插件具有以下协议的请求兼容:
http
https
Grpc
Grpcs
此插件与无DB模式兼容
名称 | 描述 |
---|---|
name | 要使用的插件的名称 http-log |
service_id | 此插件将定位的服务的ID` |
route_id | 此插件将定位的路由的ID |
enabled | 是否将应用此插件 默认值: true |
consumer_id | 将定位的Consumer的id |
config.http_endpoint | 要将数据发送到的HTTP端点(包括要使用的协议) |
config.method | 默认值:POST 用于将数据发送到http服务器的可选方法,其他支持的值是PUT ,PATCH |
config.timeout | 默认值:10000 向上游服务器发送数据时的可选超时(以毫秒为单位) |
config.keepalive | 默认值:60000 一个可选值(以毫秒为单位),用于定义空闲连接在关闭之前的生存时间 |
{
"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
}
request
包含有关客户端发送的请求的属性
response
包含有关发送到客户端的响应的属性
tries
包含负载均衡器为此请求进行的(重新)尝试(成功和失败)列表
route
包含有关所请求的特定路线的Kong属性
service
包含与所请求的路线相关联的服务的Kong属性
authenticated_entity
包含有关经过身份验证的凭据的Kong属性(如果已启用身份验证插件)
workspaces
包含与请求的路由关联的工作空间的Kong属性。仅限Kong Enterprise版本> = 0.34。
consumer
包含经过身份验证的使用者(如果已启用身份验证插件)
latencies
包含一些有关延迟的数据:
proxy
是最终服务处理请求所花费的时间kong
是运行所有插件所需的内部Kong延迟request
是从客户端读取的第一个字节之间以及最后一个字节发送到客户端之间经过的时间。用于检测慢速客户端。client_ip
包含原始客户端IP地址
started_at
包含开始处理请求的UTC时间戳。
通过UDP将请求和响应数据记录到Loggly。
具有以下协议的请求兼容:
http
https
grpc
grpcs
此插件与无DB模式兼容。
名称 | 描述 |
---|---|
name | 要使用的插件的名称 loggly |
service_id | 将定位的服务的ID |
route_id | 将定位的路由的ID |
enabled | 是否将应用此插件 默认值: true |
consumer_id | 将定位的Consumer的id |
config.host | Loggly服务器的IP地址或主机名 |
config.port | 用于将数据发送到Loggly服务器的UDP端口 默认值:514 |
config.key | Loggly 客户令牌 |
config.tags | 可选的标记列表,用于支持日志的分段和过滤。 默认值kong |
config.timeout | 将数据发送到Loggly服务器时的可选超时(以毫秒为单位) 默认值:10000 |
config.successful_severity | 可选的日志记录严重性分配给响应状态代码为400的所有成功请求。默认值:info |
config.server_errors_severity | 可选的日志记录严重性分配给响应状态代码为400或更高但小于500的所有失败请求 默认值:info |
config.server_errors_severity | 可选的日志记录严重性分配给响应状态码为500或更高的所有失败请求。默认值:info |
config.log_level | 可选的日志记录严重性,任何具有相同或更高严重性的请求都将 记 录 到 Loggly 默认值info |
每个请求都将以SYSLOG标准传输到Loggly ,其message
组件格式如下:
{
"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"
}
},
"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
}
记录服务的度量标准,路由到StatsD服务器。
此插件与具有以下协议的请求兼容:
http
https
grpc
grpcs
此插件与无DB模式兼容。
名称 | 描述 |
---|---|
name | 要使用的插件的名称 statsd |
service_id | 将定位的服务的ID |
route_id | 将定位的路由的ID |
enabled | 是否将应用此插件 |
consumer_id | 将定位的Consumer的id |
config.host | 要发送数据的IP地址或主机名 |
config.port | 将数据发送到上游服务器的端口。默认值:8125 |
config.metrics | 要记录的度量标准列表。默认值:记录所有指标 |
config.prefix | 要作为每个度量标准名称的前缀的字符串:默认值:8125 |
名称 | 描述 | 命名空间 |
---|---|---|
request_count | 跟踪请求 | kong. |
request_size | 跟踪请求的主体大小(以字节为单位 | kong. |
response_size | 跟踪响应的主体大小(以字节为单位) | kong. |
latency | 跟踪请求启动和从上游服务器接收的响应之间的时间间隔 | kong. |
status_count | 跟踪响应中返回的每个状态代码 | kong. |
unique_users | 跟踪向底层服务/路由发出请求的唯一用户 | kong. |
request_per_user | 跟踪请求/用户 | kong. |
upstream_latency | 跟踪最终服务处理请求所花费的时间 | kong. |
kong_latency | 跟踪运行所有插件所需的内部Kong延迟 | kong. |
status_count_per_user | 跟踪请求/状态/用户 | kong. |
名称 | 描述 |
---|---|
name | StatsD指标的名称 |
stat_type | 确定度量表示的事件类型 |
sample_rate | 采样率 |
customer_identifier | 客户标识符。经过身份验证的用户详 |
stat_type
设置为counter
或gauge
必须已sample_rate
定义的度量标准。unique_users
指标只适用于stat_type
作为set
。status_count
,status_count_per_user
并且request_per_user
只与工作stat_type
的counter
。status_count_per_user
,request_per_user
并且unique_users
必须已customer_identifier
定义。将请求和响应数据记录到Syslog。
此插件与具有以下协议的请求兼容:
http
https
grpc
grpcs
此插件与无DB模式兼容
名称 | 描述 |
---|---|
name | 要使用的插件的名称 sys-log |
service_id | 将定位的服务的ID |
route_id | 将定位的路由的ID |
enabled | 是否将应用此插件 默认值: true |
consumer_id | 将定位的Consumer的id |
config.successful_severity | 可选的日志记录严重性分配给响应状态代码为400的所有成功请求。默认值:info |
config.server_errors_severity | 可选的日志记录严重性分配给响应状态代码为400或更高但小于500的所有失败请求 默认值:info |
config.server_errors_severity | 可选的日志记录严重性分配给响应状态码为500或更高的所有失败请求。默认值:info |
config.log_level | 可选的日志记录严重性,任何具有相同或更高严重性的请求都将 记 录 到 Loggly 默认值info |
每个请求都将以SYSLOG标准记录到系统日志中,其message
组件格式如下:
{
"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
}
config.log_level
。将请求和响应数据记录到TCP服务器
此插件与具有以下协议的请求兼容:
http
https
grpc
grpcs
此插件与无DB模式兼容。
名称 | 描述 |
---|---|
name | 要使用的插件的名称 tcp-log |
service_id | 将定位的服务的ID |
route_id | 将定位的路由的ID |
enabled | 是否将应用此插件.默认值: true |
consumer_id | 将定位的Consumer的id |
config.host | 要发送数据的IP地址或主机名 |
config.port | 将数据发送到上游服务器的端口 |
config.timeout | 向上游服务器发送数据时的可选超时(以毫秒为单位) **默认值:**10000 |
config.keepalive | 一个可选值(以毫秒为单位),用于定义空闲连接在关闭之前的生存时间。**默认值:**60000 |
每个请求将单独记录在JSON对象中,由新行分隔\n
,格式如下:
{
"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
}
将请求和响应数据记录到UDP服务器。
此插件与具有以下协议的请求兼容:
http
https
grpc
grpcs
此插件与无DB模式兼容。
名称 | 描述 |
---|---|
name | 插件的名称 udp-log |
service_id | 定位的服务的ID |
route_id | 定位的路由的ID |
enabled | 是否将应用此插件 |
consumer_id | 定位的Consumer的id |
config.host | 要发送数据的IP地址或主机名 |
config.port | 将数据发送到上游服务器的端口 |
config.timeout | 向上游服务器发送数据时的可选超时(以毫秒为单位) |
每个请求都将使用以下格式单独记录在JSON对象中:
{
"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
}