|
@ -34,15 +34,15 @@ public class LogEndPoint {
|
|
|
|
|
|
) {
|
|
) {
|
|
List<LogModel> logs = new ArrayList<>();
|
|
List<LogModel> logs = new ArrayList<>();
|
|
StringBuffer sql = new StringBuffer("SELECT traceid, max(eventendtime) eventendtime ,min(eventstarttime) eventstarttime, max(excutetime) excutetime FROM " + adminServerProperties.getRealDefaultIndexName() + " where eventname='system_http_tracer' ");
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT traceId, max(eventEndTime) eventEndTime ,min(eventStartTime) eventStartTime, max(excuteTime) excuteTime FROM " + adminServerProperties.getRealDefaultIndexName() + " where eventName='system_http_tracer' ");
|
|
StringBuffer whereSQL = new StringBuffer();
|
|
StringBuffer whereSQL = new StringBuffer();
|
|
if (!StringUtils.isEmpty(traceId)) {
|
|
if (!StringUtils.isEmpty(traceId)) {
|
|
whereSQL.append(" and traceid='" + traceId + "'");
|
|
|
|
|
|
whereSQL.append(" and traceId='" + traceId + "'");
|
|
}
|
|
}
|
|
if (time != null && time > 0) {
|
|
if (time != null && time > 0) {
|
|
whereSQL.append(" and excutetime >" + time + "");
|
|
|
|
|
|
whereSQL.append(" and excuteTime >" + time + "");
|
|
}
|
|
}
|
|
StringBuffer groupby = new StringBuffer(" group by traceid order by eventstarttime desc limit " + (page * pageSize) + "," + pageSize);
|
|
|
|
|
|
StringBuffer groupby = new StringBuffer(" group by traceId order by eventStartTime desc limit " + (page * pageSize) + "," + pageSize);
|
|
String finalSql = sql.toString() + whereSQL.toString() + groupby.toString();
|
|
String finalSql = sql.toString() + whereSQL.toString() + groupby.toString();
|
|
List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(finalSql);
|
|
List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(finalSql);
|
|
for (int i = 0; i < traceidList.size(); i++) {
|
|
for (int i = 0; i < traceidList.size(); i++) {
|
|
@ -51,11 +51,11 @@ public class LogEndPoint {
|
|
if (value.size() == 0) {
|
|
if (value.size() == 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
logTemp.setTraceid(value.get("traceid").toString());
|
|
|
|
Long startTime = ((Double) value.get("eventstarttime")).longValue();
|
|
|
|
|
|
logTemp.setTraceid(value.get("traceId").toString());
|
|
|
|
Long startTime = ((Double) value.get("eventStartTime")).longValue();
|
|
logTemp.setEventstarttime(startTime);
|
|
logTemp.setEventstarttime(startTime);
|
|
logTemp.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
logTemp.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
Long endtime = ((Double) value.get("eventendtime")).longValue();
|
|
|
|
|
|
Long endtime = ((Double) value.get("eventEndTime")).longValue();
|
|
logTemp.setEventendtime(endtime);
|
|
logTemp.setEventendtime(endtime);
|
|
logTemp.setEventendtimestr(DateUtil.dateToStr(new Date(endtime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
logTemp.setEventendtimestr(DateUtil.dateToStr(new Date(endtime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
logs.add(logTemp);
|
|
logs.add(logTemp);
|
|
@ -80,7 +80,7 @@ public class LogEndPoint {
|
|
StringBuffer sql = new StringBuffer("SELECT * FROM " + adminServerProperties.getRealDefaultIndexName());
|
|
StringBuffer sql = new StringBuffer("SELECT * FROM " + adminServerProperties.getRealDefaultIndexName());
|
|
StringBuffer whereSQL = initWhere(traceId, spanname, eventname, time, uri, method);
|
|
StringBuffer whereSQL = initWhere(traceId, spanname, eventname, time, uri, method);
|
|
|
|
|
|
StringBuffer groupBY = new StringBuffer("order by eventstarttime "+sort);
|
|
|
|
|
|
StringBuffer groupBY = new StringBuffer("order by eventStartTime "+sort);
|
|
|
|
|
|
String finalSQL = sql.append(whereSQL).append(groupBY).toString();
|
|
String finalSQL = sql.append(whereSQL).append(groupBY).toString();
|
|
|
|
|
|
@ -90,17 +90,17 @@ public class LogEndPoint {
|
|
Map<String, Object> value = traceidList.get(i);
|
|
Map<String, Object> value = traceidList.get(i);
|
|
|
|
|
|
|
|
|
|
logTemp.setTraceid(value.get("traceid").toString());
|
|
|
|
logTemp.setSpanid(value.get("spanid").toString());
|
|
|
|
logTemp.setSpanname(value.get("spanname").toString());
|
|
|
|
logTemp.setEventname(value.get("eventname").toString());
|
|
|
|
if (value.containsKey("eventstarttime") && value.get("eventstarttime") != null) {
|
|
|
|
Long startTime = (Long) value.get("eventstarttime");
|
|
|
|
|
|
logTemp.setTraceid(value.get("traceId").toString());
|
|
|
|
logTemp.setSpanid(value.get("spanId").toString());
|
|
|
|
logTemp.setSpanname(value.get("spanName").toString());
|
|
|
|
logTemp.setEventname(value.get("eventName").toString());
|
|
|
|
if (value.containsKey("eventStartTime") && value.get("eventStartTime") != null) {
|
|
|
|
Long startTime = (Long) value.get("eventStartTime");
|
|
logTemp.setEventstarttime(startTime);
|
|
logTemp.setEventstarttime(startTime);
|
|
logTemp.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
logTemp.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
}
|
|
}
|
|
if (value.containsKey("eventendtime") && value.get("eventendtime") != null) {
|
|
|
|
Long endtime = (Long) value.get("eventendtime");
|
|
|
|
|
|
if (value.containsKey("eventEndTime") && value.get("eventEndTime") != null) {
|
|
|
|
Long endtime = (Long) value.get("eventEndTime");
|
|
logTemp.setEventendtime(endtime);
|
|
logTemp.setEventendtime(endtime);
|
|
logTemp.setEventendtimestr(DateUtil.dateToStr(new Date(endtime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
logTemp.setEventendtimestr(DateUtil.dateToStr(new Date(endtime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
}
|
|
}
|
|
@ -116,8 +116,8 @@ public class LogEndPoint {
|
|
if (value.containsKey("uri") && value.get("uri") != null) {
|
|
if (value.containsKey("uri") && value.get("uri") != null) {
|
|
logTemp.setUri(value.get("uri").toString());
|
|
logTemp.setUri(value.get("uri").toString());
|
|
}
|
|
}
|
|
if (value.containsKey("excutetime") && value.get("excutetime") != null) {
|
|
|
|
logTemp.setExcutetime((Integer) value.get("excutetime"));
|
|
|
|
|
|
if (value.containsKey("excuteTime") && value.get("excuteTime") != null) {
|
|
|
|
logTemp.setExcutetime((Integer) value.get("excuteTime"));
|
|
}
|
|
}
|
|
|
|
|
|
//设置header
|
|
//设置header
|
|
@ -145,13 +145,13 @@ public class LogEndPoint {
|
|
StringBuffer whereSQL = new StringBuffer();
|
|
StringBuffer whereSQL = new StringBuffer();
|
|
Map<String, Object> params = new HashMap<>();
|
|
Map<String, Object> params = new HashMap<>();
|
|
if (!StringUtils.isEmpty(traceId)) {
|
|
if (!StringUtils.isEmpty(traceId)) {
|
|
params.put("traceid", traceId);
|
|
|
|
|
|
params.put("traceId", traceId);
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(spanname)) {
|
|
if (!StringUtils.isEmpty(spanname)) {
|
|
params.put("spanname", spanname);
|
|
|
|
|
|
params.put("spanName", spanname);
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(eventname)) {
|
|
if (!StringUtils.isEmpty(eventname)) {
|
|
params.put("eventname", eventname);
|
|
|
|
|
|
params.put("eventName", eventname);
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(uri)) {
|
|
if (!StringUtils.isEmpty(uri)) {
|
|
params.put("uri", uri);
|
|
params.put("uri", uri);
|
|
@ -165,7 +165,7 @@ public class LogEndPoint {
|
|
String key = " where ";
|
|
String key = " where ";
|
|
for (Map.Entry<String, Object> one : params.entrySet()) {
|
|
for (Map.Entry<String, Object> one : params.entrySet()) {
|
|
if ("time".equals(one.getKey())) {
|
|
if ("time".equals(one.getKey())) {
|
|
whereSQL.append(key).append("excutetime > '" + one.getValue() + "'");
|
|
|
|
|
|
whereSQL.append(key).append("excuteTime > '" + one.getValue() + "'");
|
|
} else if ("uri".equals(one.getKey())) {
|
|
} else if ("uri".equals(one.getKey())) {
|
|
whereSQL.append(key).append("uri like '%" + one.getValue() + "%'");
|
|
whereSQL.append(key).append("uri like '%" + one.getValue() + "%'");
|
|
} else {
|
|
} else {
|
|
@ -183,8 +183,8 @@ public class LogEndPoint {
|
|
@RequestParam(value = "spanname", required = true) String spanname) {
|
|
@RequestParam(value = "spanname", required = true) String spanname) {
|
|
spanname = spanname.toLowerCase();
|
|
spanname = spanname.toLowerCase();
|
|
List<QuotaModel> logs = new ArrayList<>();
|
|
List<QuotaModel> logs = new ArrayList<>();
|
|
StringBuffer sql = new StringBuffer("SELECT uri,sum(success) success,sum(fail) fail,avg(excutetime) avgtime ,max(excutetime) maxtime ,count(*) allcount FROM " + adminServerProperties.getRealDefaultIndexName() + " " +
|
|
|
|
" where spanname ='" + spanname + "' and eventname='system_http_tracer' " +
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT uri,sum(success) success,sum(fail) fail,avg(excuteTime) avgtime ,max(excuteTime) maxtime ,count(*) allcount FROM " + adminServerProperties.getRealDefaultIndexName() + " " +
|
|
|
|
" where spanName ='" + spanname + "' and eventName='system_http_tracer' " +
|
|
" group by uri ");
|
|
" group by uri ");
|
|
List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(sql.toString());
|
|
List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(sql.toString());
|
|
if (traceidList.size() > 0) {
|
|
if (traceidList.size() > 0) {
|
|
@ -211,17 +211,17 @@ public class LogEndPoint {
|
|
@RequestParam(value = "spanname", required = true) String spanname) {
|
|
@RequestParam(value = "spanname", required = true) String spanname) {
|
|
spanname = spanname.toLowerCase();
|
|
spanname = spanname.toLowerCase();
|
|
List<QuotaSQLModel> logs = new ArrayList<>();
|
|
List<QuotaSQLModel> logs = new ArrayList<>();
|
|
StringBuffer sql = new StringBuffer("SELECT sql,excutetime,eventstarttime FROM " + adminServerProperties.getRealDefaultIndexName() + " " +
|
|
|
|
" where spanname ='" + spanname + "' and eventname='system_sql_springJDBC_tracer' and eventtime>1500 ");
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT sql,excuteTime,eventStartTime FROM " + adminServerProperties.getRealDefaultIndexName() + " " +
|
|
|
|
" where spanName ='" + spanname + "' and eventName='system_sql_springJDBC_tracer' and eventTime>1500 ");
|
|
List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(sql.toString());
|
|
List<Map<String, Object>> traceidList = elastricSearchHelper.excuceSQL(sql.toString());
|
|
if (traceidList.size() > 0) {
|
|
if (traceidList.size() > 0) {
|
|
for (Map<String, Object> one : traceidList) {
|
|
for (Map<String, Object> one : traceidList) {
|
|
if (one.size() > 0) {
|
|
if (one.size() > 0) {
|
|
QuotaSQLModel quotaSQLModel = new QuotaSQLModel();
|
|
QuotaSQLModel quotaSQLModel = new QuotaSQLModel();
|
|
quotaSQLModel.setSql(one.get("sql").toString());
|
|
quotaSQLModel.setSql(one.get("sql").toString());
|
|
quotaSQLModel.setExcutetime(Double.valueOf(one.get("excutetime").toString()).intValue());
|
|
|
|
if (one.containsKey("eventstarttime") && one.get("eventstarttime") != null) {
|
|
|
|
Long startTime = (Long) one.get("eventstarttime");
|
|
|
|
|
|
quotaSQLModel.setExcutetime(Double.valueOf(one.get("excuteTime").toString()).intValue());
|
|
|
|
if (one.containsKey("eventStartTime") && one.get("eventStartTime") != null) {
|
|
|
|
Long startTime = (Long) one.get("eventStartTime");
|
|
quotaSQLModel.setEventstarttime(startTime);
|
|
quotaSQLModel.setEventstarttime(startTime);
|
|
quotaSQLModel.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
quotaSQLModel.setEventstarttimestr(DateUtil.dateToStr(new Date(startTime), DateUtil.YYYY_MM_DD_HH_MM_SS_SSS));
|
|
}
|
|
}
|