Authored by wangning

Merge branch 'wn1020'

... ... @@ -23,6 +23,8 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
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')";
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
//根据context获取总响应次数和平均耗时
@Override
public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) {
... ... @@ -397,7 +399,13 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
@Override
public List<Map> getAlarmData(Integer costThreshold){
String sql = String.format("select count(cost),mean(cost) from service_access where %s and time > now() - 10s group by hostAddress,context;select count(cost) from service_access where %s and time > now() - 10s and cost > %d group by hostAddress,context",contextFilter,contextFilter,costThreshold);
DateTime endDateTime = DateTime.now(DateTimeZone.UTC);
DateTime startDateTime = endDateTime.minusSeconds(10);
String startDateStr = startDateTime.toString(DATE_TIME_FORMAT);
String endDateStr = endDateTime.toString(DATE_TIME_FORMAT);
String sql1 = String.format("select count(cost),mean(cost) from service_access where %s and time > '%s' and time < '%s' group by hostAddress,context;",contextFilter,startDateStr,endDateStr);
String sql2 = String.format("select count(cost) from service_access where %s and time > '%s' and time < '%s' and cost > %d group by hostAddress,context",contextFilter,startDateStr,endDateStr,costThreshold);
String sql = sql1 + sql2;
List<Map> list = new ArrayList<>();
list.addAll(getAlarmData(InfluxDBContants.AWS,sql));
list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql));
... ...