Commit 89f49b27 by 宋毅

tj

parent 280bf159
...@@ -16,7 +16,10 @@ class APIBase { ...@@ -16,7 +16,10 @@ class APIBase {
if (!pobj.actionBody) { if (!pobj.actionBody) {
pobj.actionBody = {}; pobj.actionBody = {};
} }
pobj.actionBody.requestId = pobj.requestId ? pobj.requestId : pobj.actionBody.requestId || await this.getBusUid("mq-"); pobj.actionBody.requestId = pobj.requestId ? pobj.requestId : pobj.actionBody.requestId;
if (pobj.actionType && pobj.actionType != "queryLogsData" && !pobj.actionBody.requestId) {
pobj.actionBody.requestId = await this.getBusUid("mq-");
}
var shaStr = await sha256(JSON.stringify(pobj)); var shaStr = await sha256(JSON.stringify(pobj));
this.redisClient.setWithEx(shaStr, 1, 3); this.redisClient.setWithEx(shaStr, 1, 3);
var result = await this[methodname](pobj, query, req); var result = await this[methodname](pobj, query, req);
...@@ -30,7 +33,9 @@ class APIBase { ...@@ -30,7 +33,9 @@ class APIBase {
pobj.actionBody.resultInfo = result; pobj.actionBody.resultInfo = result;
pobj.actionBody.requestId = result.requestId; pobj.actionBody.requestId = result.requestId;
pobj.actionBody.opTitle = "reqPath:" + req.path; pobj.actionBody.opTitle = "reqPath:" + req.path;
this.esUtils.addEsLogs(settings.queuedName + "-apireq", pobj.actionBody); if (pobj.actionType && pobj.actionType != "queryLogsData") {
this.esUtils.addEsLogs(settings.queuedName + "-apireq", pobj.actionBody);
}
} }
return result; return result;
} catch (error) { } catch (error) {
......
...@@ -58,7 +58,7 @@ class UtilsLogsService extends AppServiceBase { ...@@ -58,7 +58,7 @@ class UtilsLogsService extends AppServiceBase {
, ,
"sort": [ "sort": [
{ {
"created_at": "desc" "timestamp": "desc"
} }
] ]
} }
...@@ -103,6 +103,16 @@ class UtilsLogsService extends AppServiceBase { ...@@ -103,6 +103,16 @@ class UtilsLogsService extends AppServiceBase {
} }
}); });
} }
if (actionBody.startTime && actionBody.entTime) {
params.query.bool["filter"] = {
"range": {
"timestamp": {
"gte": actionBody.startTime,
"lte": actionBody.entTime
}
}
};
}
var resultData = null; var resultData = null;
try { try {
resultData = await this.esUtils.execPostEs(settings.queuedName, params, esIndexName); resultData = await this.esUtils.execPostEs(settings.queuedName, params, esIndexName);
......
...@@ -114,7 +114,9 @@ ...@@ -114,7 +114,9 @@
"messageBody":"",//N 日志的描述信息 "messageBody":"",//N 日志的描述信息
"resultInfo":"",//N 返回信息 "resultInfo":"",//N 返回信息
"errorInfo": "",//N 错误信息 "errorInfo": "",//N 错误信息
"requestId": ""//N 请求返回的requestId "requestId": "",//N 请求返回的requestId
"startTime":1595414873130,//N 开始时间
"entTime":1595414873132//N 结束时间
} }
} }
返回参数: 返回参数:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment