调试配置
当服务上线后,为了更精确的分析线上的结果,需要汇总各种信息。
在线下可以打印日志调试,当服务上线后,无法灵活的进行打印。
本配置主要收集线上调试信息,并能灵活的开启,或打印到终端,或者输出到 datahub 上进行更细致的分析,或输出到本地文件供进行其它调用。
目前主要收集的是召回、过滤、粗排之后的 items 数据。
调试配置对应配置总览中的 DebugConfs,DebugConfs 是一个 Map[string]object 结构,其中 key 是场景,可以对不同的场景进行配置隔离。
"DebugConfs": {
"scene_name": {
"OutputType": "datahub",
"Rate": 0,
"DebugUsers": [
"1001"
],
"DatahubName": "dh_debug_log",
"FilePath": "/Users/username/pairec/debug_log/",
"MaxFileNum": 20
}
}
字段名 | 类型 | 是否必填 | 描述 |
OutputType | string | 是 | 调试日志的输出方式,枚举值
|
Rate | int | 是 | 日志的采样比例,取之范围 0-100,当为 0 时,不输出调试信息 可以根据线上服务的 qps 适当调整 |
DebugUsers | []string | 否 | 只对某些 uid 进行日志记录。例如 "DebugUsers": [ "1001"],表示只对 1001 这个 user 记录日志,其他 user 不记录。 |
DatahubName | string | 否 | 当 OutputType=datahub 时,需要填写此参数。 来源于数据源配置中的 DatahubConfs 的自定义名称 |
FilePath | string | 否 | 当 OutputType=file 时,需要填写此参数。 会将 debug 日志输出到此路径,路径不存在时会自动创建。 |
MaxFileNum | int | 否 | 当 OutputType=file 时,可以选择性填写此参数。 设置 FilePath 路径中可保存的最大日志数量,默认为20。路径中每个日志文件大小限制为1G,超过会进行文件轮转。 若文件数量超过 MaxFileNum,会删除最旧的日志文件。 |
目前输出的信息包括如下:
request_id 请求标识
module 标识哪个模块的日志,目前包括 recall, filter, general_rank
scene_id 场景id
exp_id 实验id
request_time 请求时间戳,秒为单位
uid 用户id
retrieveid 召回id
items item list 列表,格式为 "item1:score1,item2:score2", 这里 score 可以理解为,当 module = recall 时, score 为召回得分。 module=general_rank, score 为粗排得分
目前在某个 module 下, items 是分 retrieveid 进行输出的。比如有5个召回源,那么在 module = recall 时, 会有5条记录,每条记录对应一路召回。同样,filter, general_rank 也是按此逻辑打印。
Datahub 配置
在 Datahub 配置中,可以不用创建 topic, 只要指定 topic , schemas , 引擎会自动创建。
{
"DatahubConfs": {
"dh_debug_log": {
"Endpoint": "http://dh-cn-beijing-int-vpc.aliyuncs.com",
"AccessId": "${AccessKey}",
"AccessKey": "${AccessSecret}",
"ProjectName": "",
"TopicName": "pairec_debug_log",
"Schemas": [
{
"Field": "request_id",
"Type": "string"
},
{
"Field": "module",
"Type": "string"
},
{
"Field": "scene_id",
"Type": "string"
},
{
"Field": "request_time",
"Type": "integer"
},
{
"Field": "exp_id",
"Type": "string"
},
{
"Field": "items",
"Type": "string"
},
{
"Field": "retrieveid",
"Type": "string"
},
{
"Field": "uid",
"Type": "string"
}
]
}
}
}
注:如果使用 PAI-REC 控制台进行配置,为了保持安全性,${AccessKey}:${AccessSecret} 可以不用替换,引擎会自动替换。
当运行服务时,引擎会自动创建此 Topic: pairec_debug_log, 并使用上面的 schema。 当在 datahub 控制台,看到有日志输出时,可以自行创建 MaxCompute 与 datahub 的订阅关系。
- 本页导读 (0)