概述
云原生网关对接天翼云日志服务(LTS)实现了访问日志采集、上报和查询能力;使用此功能前需要先开通云日志服务,同时在云原生网关控制台开启日志功能。
每个云原生网关实例在云日志服务中会创建一个日志项目,项目名称为MSEGW-${网关实例名称},项目内有一个日志单元对应访问日志,单元名称为网关实例名称,您可以在云原生网关控制台 观测分析 > 日志中心 菜单 或者在云日志服务控制台查看网关访问日志。
访问日志格式说明
网关访问日志示例
{"start_time":1725411921254,"request":{"size":335,"method":"POST","uri":"/foo/bar","headers":{"accept":"text/plain, application/json, application/*+json, */*","content-length":"0","uber-trace-id":"b32bce4ff1f00f7b:899a1fd65c39be02:1c3372663d9eae03:0","connection":"keep-alive","user-agent":"Java/1.8.0_212","host":"foo.ctyun.com","content-type":"application/json"},"url":"http://foo.ctyun.com:27151/foo/bar","querystring":{}},"service_id":"a4db25fc03294d5dbeb9e7752381c972","server":{"version":"3.2.2","hostname":"msegw-vmxxxxxx"},"apisix_latency":0,"latency":24.00016784668,"client_ip":"100.89.x.x","response":{"size":625,"headers":{"via":"1.1 alb/v3.4.5","content-length":"427","date":"Wed, 04 Sep 2024 01:05:21 GMT","connection":"close","server":"MSEGW/3.2.2","content-type":"application/json;charset=UTF-8"},"status":400},"upstream":{"upstream_addr":"10.121.x.x:80","upstream_status":"400","upstream_latency":25,"upstream_name":"foo-service"},"route_id":"ddd342a2a3f34405bb8650ad4e","route_name":"test-route"}
访问日志字段说明如下
字段 | 说明 |
---|---|
start_time | 请求开始时间 |
request | 请求信息 |
service_id | 服务id |
server | 网关节点信息 |
apisix_latency | 网关自身处理耗时(不包括上游服务耗时) |
latency | 总请求耗时(网关处理耗时和上游服务耗时之和) |
client_ip | 客户端IP |
response | 应答信息 |
upstream | 上游信息,包括上游地址,上游返回的HTTP状态码,上游耗时;当服务访问异常时可以重点关注此字段,确认是否时上游服务出了问题。 |
route_id | 路由id |
route_name | 路由名称 |