M-11-log-storage.json
3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
"id": "M-11",
"name": "原始日志存储服务",
"fileKey": "log-storage",
"desc": "混合日志存储服务,结构化数据写入 MySQL,原始请求/响应 JSON 写入文件系统",
"apis": [
{
"method": "POST",
"path": "/api/v1/internal/logs/write",
"name": "写入结构化日志",
"description": "结构化数据写入 MySQL(ai_llmbase_call_records 表)",
"params": [
{"name": "call_record_id", "in": "body", "type": "string", "required": true, "desc": "调用记录 ID"},
{"name": "request_body", "in": "body", "type": "object", "required": true, "desc": "请求体 JSON"},
{"name": "response_body", "in": "body", "type": "object", "required": false, "desc": "响应体 JSON"},
{"name": "prompt_tokens", "in": "body", "type": "integer", "required": false, "desc": "Prompt Token 消耗"},
{"name": "completion_tokens", "in": "body", "type": "integer", "required": false, "desc": "Completion Token 消耗"},
{"name": "total_tokens", "in": "body", "type": "integer", "required": false, "desc": "总 Token 消耗"},
{"name": "duration_ms", "in": "body", "type": "integer", "required": false, "desc": "调用耗时(毫秒)"},
{"name": "status", "in": "body", "type": "string", "required": true, "desc": "状态:success/failed"},
{"name": "error_message", "in": "body", "type": "string", "required": false, "desc": "错误信息"}
],
"responses": [
{"code": 200, "desc": "写入成功", "schema": ""},
{"code": 500, "desc": "写入失败", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/internal/logs/write 请求"},
{"tag": "validate", "text": "验证请求参数"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "return", "text": "返回操作结果"}
]
},
{
"method": "POST",
"path": "/api/v1/internal/logs/write-file",
"name": "写入原始日志文件",
"description": "原始请求/响应 JSON 写入文件系统(logs/calls/YYYY-MM-DD/{request_id}.json)",
"params": [
{"name": "request_id", "in": "body", "type": "string", "required": true, "desc": "请求 ID"},
{"name": "request_body", "in": "body", "type": "object", "required": true, "desc": "原始请求 JSON"},
{"name": "response_body", "in": "body", "type": "object", "required": false, "desc": "原始响应 JSON"}
],
"responses": [
{"code": 200, "desc": "写入成功", "schema": ""},
{"code": 500, "desc": "写入失败", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/internal/logs/write-file 请求"},
{"tag": "validate", "text": "验证请求参数"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "return", "text": "返回操作结果"}
]
},
{
"method": "POST",
"path": "/api/v1/internal/logs/archive",
"name": "超期日志归档",
"description": "超期日志自动归档/清理(可配置保留天数)",
"params": [
{"name": "retention_days", "in": "body", "type": "integer", "required": false, "desc": "保留天数(默认从配置读取)"}
],
"responses": [
{"code": 200, "desc": "归档完成", "schema": "{archived_count}"}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/internal/logs/archive 请求"},
{"tag": "validate", "text": "验证请求参数"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "return", "text": "返回操作结果"}
]
}
]
}