...
|
...
|
@@ -28,7 +28,12 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) {
|
|
|
|
|
|
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
|
|
|
String sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
String sql = "";
|
|
|
if(req.getServiceType() == -1){
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where time > '%s' and time < '%s' group by hostAddress",req.getStartTime(),req.getEndTime());
|
|
|
}else{
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
|
|
|
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
|
...
|
...
|
@@ -60,7 +65,13 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
@Override
|
|
|
public Map<String,List<String>> getTimeoutInfo(NewJavaApiInfoReq req) {
|
|
|
Map<String,List<String>> map = new HashMap();
|
|
|
String sql = String.format("select ip,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
String sql = "";
|
|
|
if(req.getServiceType() == -1){
|
|
|
sql = String.format("select ip,stack from service_access where cost > 200 and time > '%s' and time < '%s'",req.getStartTime(),req.getEndTime());
|
|
|
}else{
|
|
|
sql = String.format("select ip,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
|
|
|
map.putAll(getTimeoutInfo(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getTimeoutInfo(InfluxDBContants.Q_CLOUD,sql));
|
|
|
return map;
|
...
|
...
|
@@ -160,12 +171,20 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
}else{
|
|
|
source = InfluxDBContants.AWS;
|
|
|
}
|
|
|
|
|
|
if(req.getServiceType() == -1){
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and hostAddress = '%s' and time > '%s' and time < '%s' group by event",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where hostAddress = '%s' and time > '%s' and time < '%s' group by event,context",req.getIp(),req.getStartTime(),req.getEndTime());
|
|
|
}else{
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by event",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where time > '%s' and time < '%s' group by event,context",req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}else{
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and hostAddress = '%s' and time > '%s' and time < '%s' group by event,context",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
|
|
|
}else{
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by event,context",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
...
|
...
|
@@ -175,11 +194,13 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
for(QueryResult.Series series : listSeries){
|
|
|
NewJavaApiDetailInfoRep rep = new NewJavaApiDetailInfoRep();
|
|
|
String apiName = series.getTags().get("event");
|
|
|
String serviceName = series.getTags().get("context");
|
|
|
Double count = (Double)series.getValues().get(0).get(1);
|
|
|
Double mean = (Double)series.getValues().get(0).get(2);
|
|
|
rep.setApiName(apiName);
|
|
|
rep.setTotalCount(count.intValue());
|
|
|
rep.setAvgCost(mean.intValue());
|
|
|
rep.setServiceName(serviceName);
|
|
|
list.add(rep);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -196,12 +217,20 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
}else{
|
|
|
source = InfluxDBContants.AWS;
|
|
|
}
|
|
|
|
|
|
if(req.getServiceType() == -1){
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s' and ip = '%s' ",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp());
|
|
|
}else{
|
|
|
sql = String.format("select event,stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}else{
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
sql = String.format("select event,stack from service_access where cost > 200 and time > '%s' and time < '%s' and ip = '%s' ",req.getStartTime(),req.getEndTime(),req.getIp());
|
|
|
}else{
|
|
|
sql = String.format("select event,stack from service_access where cost > 200 and time > '%s' and time < '%s'",req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,List<String>> map = new HashMap();
|
...
|
...
|
|