...
|
...
|
@@ -23,6 +23,8 @@ import java.util.*; |
|
|
@Component
|
|
|
public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAccessMapper {
|
|
|
|
|
|
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')";
|
|
|
|
|
|
//根据context获取总响应次数和平均耗时
|
|
|
@Override
|
|
|
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) {
|
...
|
...
|
@@ -30,7 +32,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
|
|
|
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());
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where %s and time > '%s' and time < '%s' group by hostAddress",contextFilter,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());
|
|
|
}
|
...
|
...
|
@@ -67,7 +69,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
Map<String,List<String>> map = new HashMap();
|
|
|
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());
|
|
|
sql = String.format("select ip,stack from service_access where %s and cost > 200 and time > '%s' and time < '%s'",contextFilter,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());
|
|
|
}
|
...
|
...
|
@@ -161,7 +163,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
|
|
|
@Override
|
|
|
public Map<String,List> getServiceNameJavaApiGraph(String source){
|
|
|
String sql = "SELECT mean(cost) FROM service_access WHERE time > now() - 10m GROUP BY context,time(1m) fill(null)";
|
|
|
String sql = String.format("SELECT mean(cost) FROM service_access WHERE %s and time > now() - 10m GROUP BY context,time(1m) fill(null)",contextFilter);
|
|
|
Map<String,List> resultMap = new HashMap<>();
|
|
|
|
|
|
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
|
...
|
...
|
@@ -213,9 +215,9 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
}
|
|
|
if(req.getServiceType() == -1){
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
|
|
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());
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where %s and hostAddress = '%s' and time > '%s' and time < '%s' group by event,context",contextFilter,req.getIp(),req.getStartTime(),req.getEndTime());
|
|
|
}else{
|
|
|
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());
|
|
|
sql = String.format("select count(cost),mean(cost) from service_access where %s and time > '%s' and time < '%s' group by event,context",contextFilter,req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}else{
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
...
|
...
|
@@ -259,9 +261,9 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
}
|
|
|
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());
|
|
|
sql = String.format("select event,stack from service_access where %s and context='%s' and cost > 200 and time > '%s' and time < '%s' and ip = '%s' ",contextFilter,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());
|
|
|
sql = String.format("select event,stack from service_access where %s and context='%s' and cost > 200 and time > '%s' and time < '%s'",contextFilter,req.getServiceName(),req.getStartTime(),req.getEndTime());
|
|
|
}
|
|
|
}else{
|
|
|
if(StringUtils.isNotBlank(req.getIp())){
|
...
|
...
|
|