...
|
...
|
@@ -21,6 +21,42 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S |
|
|
|
|
|
private String contextFilter = "(context = 'gateway' or context = 'order' or context = 'promotion' or context = 'product' or context = 'message' or context = 'sns' or context = 'users' or context = 'resources' or context = 'brower')";
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public Map<String,Integer> getErrorCount(NewJavaApiInfoReq req) {
|
|
|
Map<String,Integer> map = new HashMap();
|
|
|
String sql = "";
|
|
|
if(req.getServiceType() == -1){
|
|
|
sql = String.format("select count(cost) from service_server_exception where %s and time > '%s' and time < '%s' group by hostAddress",contextFilter,req.getStartTime(),req.getEndTime());
|
|
|
}else{
|
|
|
sql = String.format("select count(cost) from service_server_exception where context='%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
|
|
|
map.putAll(getErrorCount(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getErrorCount(InfluxDBContants.Q_CLOUD,sql));
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
|
|
|
private Map<String,Integer> getErrorCount(String source,String sql) {
|
|
|
Map<String,Integer> map = new HashMap<>();
|
|
|
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
|
|
return map;
|
|
|
for(QueryResult.Series series : listSeries){
|
|
|
String hostAddress = series.getTags().get("hostAddress");
|
|
|
Double count = (Double)series.getValues().get(0).get(1);
|
|
|
map.put(hostAddress,count.intValue());
|
|
|
}
|
|
|
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据context获取错误信息列表
|
|
|
@Override
|
|
|
public Map<String,List<String>> getErrorDataByContext(NewJavaApiInfoReq req) {
|
...
|
...
|
@@ -162,6 +198,33 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S |
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String,Integer> getErrorCountByContextAndIp(NewJavaApiInfoReq req) {
|
|
|
Map<String,List<String>> map = new HashMap();
|
|
|
String source = "";
|
|
|
String sql = "";
|
|
|
if(req.getCloudType()==2){
|
|
|
source = InfluxDBContants.Q_CLOUD;
|
|
|
}else{
|
|
|
source = InfluxDBContants.AWS;
|
|
|
}
|
|
|
|
|
|
if(req.getServiceType() == -1){
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
sql = String.format("select count(cost) from service_server_exception where %s and time > '%s' and time < '%s' and hostAddress = '%s' group by event",contextFilter,req.getStartTime(),req.getEndTime(),req.getIp());
|
|
|
}else{
|
|
|
sql = String.format("select count(cost) from service_server_exception where %s and time > '%s' and time < '%s' group by event",contextFilter,req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}else{
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
sql = String.format("select count(cost) from service_server_exception where context='%s' and time > '%s' and time < '%s' and hostAddress = '%s' group by event",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp());
|
|
|
}else{
|
|
|
sql = String.format("select count(cost) from service_server_exception where context='%s' and time > '%s' and time < '%s' group by event",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return getErrorCount(source,sql);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Map<String,List<String>> getErrorDataByContextAndIp(NewJavaApiInfoReq req) {
|
...
|
...
|
|