...
|
...
|
@@ -383,12 +383,12 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
|
|
|
@Override
|
|
|
public List<Map> getAlarmData(Integer costThreshold){
|
|
|
DateTime endDateTime = DateTime.now(DateTimeZone.UTC);
|
|
|
DateTime endDateTime = DateTime.now(DateTimeZone.UTC).minusSeconds(10);
|
|
|
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 sql1 = 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 sql2 = 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 sql = sql1 + sql2;
|
|
|
log.info("getAlarmData sql is " + sql);
|
|
|
List<Map> list = new ArrayList<>();
|
...
|
...
|
@@ -407,24 +407,24 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc |
|
|
List<QueryResult.Series> listSeries2 = rel2.getSeries();
|
|
|
if(listSeries1 == null || listSeries2 == null)
|
|
|
return returnList;
|
|
|
Map<String,QueryResult.Series> map1 = new HashMap();
|
|
|
for(QueryResult.Series series1 : listSeries1){
|
|
|
String hostAddress = series1.getTags().get("hostAddress");
|
|
|
String serviceName = series1.getTags().get("context");
|
|
|
map1.put(hostAddress+"_" + serviceName,series1);
|
|
|
}
|
|
|
|
|
|
|
|
|
Map<String,QueryResult.Series> map2 = new HashMap();
|
|
|
for(QueryResult.Series series2 : listSeries2){
|
|
|
String hostAddress = series2.getTags().get("hostAddress");
|
|
|
String serviceName = series2.getTags().get("context");
|
|
|
Double count2 = (Double)series2.getValues().get(0).get(1);
|
|
|
QueryResult.Series series1 = map1.get(hostAddress+"_" + serviceName);
|
|
|
if(series1 != null){
|
|
|
Double count1 = (Double)series1.getValues().get(0).get(1);
|
|
|
Double mean = (Double)series1.getValues().get(0).get(2);
|
|
|
Double ratio = count2 / count1;
|
|
|
log.info("count2:" + count2 + ",count1:" + count1 + ",ratio:" + ratio + ",mean:" + mean);
|
|
|
map2.put(hostAddress+"_" + serviceName,series2);
|
|
|
}
|
|
|
|
|
|
|
|
|
for(QueryResult.Series series1 : listSeries1){
|
|
|
String hostAddress = series1.getTags().get("hostAddress");
|
|
|
String serviceName = series1.getTags().get("context");
|
|
|
Double timeoutCount = (Double)series1.getValues().get(0).get(1);
|
|
|
QueryResult.Series series2 = map2.get(hostAddress+"_" + serviceName);
|
|
|
if(series2 != null){
|
|
|
Double totalCount = (Double)series2.getValues().get(0).get(1);
|
|
|
Double mean = (Double)series2.getValues().get(0).get(2);
|
|
|
Double ratio = timeoutCount / totalCount;
|
|
|
log.info("hostAddress:" + hostAddress + ",serviceName:" + serviceName + ",timeoutCount:" + timeoutCount + ",totalCount:" + totalCount + ",ratio:" + ratio + ",mean:" + mean);
|
|
|
if(ratio >= 0.95){
|
|
|
Map map = new HashMap();
|
|
|
map.put("hostAddress",hostAddress);
|
...
|
...
|
|