Showing
6 changed files
with
27 additions
and
8 deletions
@@ -24,6 +24,9 @@ public class SnsMobileConfig { | @@ -24,6 +24,9 @@ public class SnsMobileConfig { | ||
24 | @Value("${java_service_alarm_cost_threshold}") | 24 | @Value("${java_service_alarm_cost_threshold}") |
25 | private Integer javaServiceCostThreshold; | 25 | private Integer javaServiceCostThreshold; |
26 | 26 | ||
27 | + @Value("${java_service_alarm_count_threshold}") | ||
28 | + private Integer javaServiceCountThreshold; | ||
29 | + | ||
27 | public String getBaseMobile() { | 30 | public String getBaseMobile() { |
28 | return baseMobile; | 31 | return baseMobile; |
29 | } | 32 | } |
@@ -64,4 +67,12 @@ public class SnsMobileConfig { | @@ -64,4 +67,12 @@ public class SnsMobileConfig { | ||
64 | public void setJavaServiceCostThreshold(Integer javaServiceCostThreshold) { | 67 | public void setJavaServiceCostThreshold(Integer javaServiceCostThreshold) { |
65 | this.javaServiceCostThreshold = javaServiceCostThreshold; | 68 | this.javaServiceCostThreshold = javaServiceCostThreshold; |
66 | } | 69 | } |
70 | + | ||
71 | + public Integer getJavaServiceCountThreshold() { | ||
72 | + return javaServiceCountThreshold; | ||
73 | + } | ||
74 | + | ||
75 | + public void setJavaServiceCountThreshold(Integer javaServiceCountThreshold) { | ||
76 | + this.javaServiceCountThreshold = javaServiceCountThreshold; | ||
77 | + } | ||
67 | } | 78 | } |
@@ -32,5 +32,5 @@ public interface ServiceAccessMapper { | @@ -32,5 +32,5 @@ public interface ServiceAccessMapper { | ||
32 | 32 | ||
33 | Map<String,Integer> getTimeoutCountByContextAndApiName(NewJavaApiInfoReq req); | 33 | Map<String,Integer> getTimeoutCountByContextAndApiName(NewJavaApiInfoReq req); |
34 | 34 | ||
35 | - List<Map> getAlarmData(Integer costThreshold); | 35 | + List<Map> getAlarmData(Integer costThreshold,Integer countThreshold); |
36 | } | 36 | } |
monitor-service-influxdb/src/main/java/com/monitor/influxdb/mapper/impl/ServiceAccessMapperImpl.java
@@ -382,7 +382,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | @@ -382,7 +382,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | ||
382 | } | 382 | } |
383 | 383 | ||
384 | @Override | 384 | @Override |
385 | - public List<Map> getAlarmData(Integer costThreshold){ | 385 | + public List<Map> getAlarmData(Integer costThreshold,Integer countThreshold){ |
386 | DateTime endDateTime = DateTime.now(DateTimeZone.UTC).minusSeconds(10); | 386 | DateTime endDateTime = DateTime.now(DateTimeZone.UTC).minusSeconds(10); |
387 | DateTime startDateTime = endDateTime.minusSeconds(10); | 387 | DateTime startDateTime = endDateTime.minusSeconds(10); |
388 | String startDateStr = startDateTime.toString(DATE_TIME_FORMAT); | 388 | String startDateStr = startDateTime.toString(DATE_TIME_FORMAT); |
@@ -392,12 +392,12 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | @@ -392,12 +392,12 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | ||
392 | String sql = sql1 + sql2; | 392 | String sql = sql1 + sql2; |
393 | log.info("getAlarmData sql is " + sql); | 393 | log.info("getAlarmData sql is " + sql); |
394 | List<Map> list = new ArrayList<>(); | 394 | List<Map> list = new ArrayList<>(); |
395 | - list.addAll(getAlarmData(InfluxDBContants.AWS,sql)); | ||
396 | - list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql)); | 395 | + list.addAll(getAlarmData(InfluxDBContants.AWS,sql,countThreshold)); |
396 | + list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql,countThreshold)); | ||
397 | return list; | 397 | return list; |
398 | } | 398 | } |
399 | 399 | ||
400 | - private List<Map> getAlarmData(String source,String sql){ | 400 | + private List<Map> getAlarmData(String source,String sql,Integer countThreshold){ |
401 | 401 | ||
402 | List<Map> returnList = new ArrayList<>(); | 402 | List<Map> returnList = new ArrayList<>(); |
403 | QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT); | 403 | QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT); |
@@ -425,7 +425,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | @@ -425,7 +425,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | ||
425 | Double mean = (Double)series2.getValues().get(0).get(2); | 425 | Double mean = (Double)series2.getValues().get(0).get(2); |
426 | Double ratio = timeoutCount / totalCount; | 426 | Double ratio = timeoutCount / totalCount; |
427 | log.info("hostAddress:" + hostAddress + ",serviceName:" + serviceName + ",timeoutCount:" + timeoutCount + ",totalCount:" + totalCount + ",ratio:" + ratio + ",mean:" + mean); | 427 | log.info("hostAddress:" + hostAddress + ",serviceName:" + serviceName + ",timeoutCount:" + timeoutCount + ",totalCount:" + totalCount + ",ratio:" + ratio + ",mean:" + mean); |
428 | - if(ratio >= 0.95){ | 428 | + if((ratio >= 0.95) && (totalCount > countThreshold)){ |
429 | Map map = new HashMap(); | 429 | Map map = new HashMap(); |
430 | map.put("hostAddress",hostAddress); | 430 | map.put("hostAddress",hostAddress); |
431 | map.put("serviceName",serviceName); | 431 | map.put("serviceName",serviceName); |
@@ -376,9 +376,15 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService { | @@ -376,9 +376,15 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService { | ||
376 | if(costThreshold == null){ | 376 | if(costThreshold == null){ |
377 | costThreshold = 300; | 377 | costThreshold = 300; |
378 | } | 378 | } |
379 | + | ||
380 | + Integer countThreshold = snsMobileConfig.getJavaServiceCountThreshold(); | ||
381 | + if(countThreshold == null){ | ||
382 | + countThreshold = 50; | ||
383 | + } | ||
384 | + | ||
379 | String nowString = DateTime.now().minusSeconds(10).toString("yyyy-MM-dd HH:mm:ss"); | 385 | String nowString = DateTime.now().minusSeconds(10).toString("yyyy-MM-dd HH:mm:ss"); |
380 | - log.info("sendAlarmMsg nowString is :" + nowString + ",costThreshold is " + costThreshold); | ||
381 | - List<Map> list = serviceAccessMapper.getAlarmData(costThreshold); | 386 | + log.info("sendAlarmMsg nowString is :" + nowString + ",costThreshold is " + costThreshold + ",countThreshold is " + countThreshold); |
387 | + List<Map> list = serviceAccessMapper.getAlarmData(costThreshold,countThreshold); | ||
382 | //获取cpu、内存、带宽使用情况 | 388 | //获取cpu、内存、带宽使用情况 |
383 | Map vmInfoMap = vmInfoMapper.getVMInfo(); | 389 | Map vmInfoMap = vmInfoMapper.getVMInfo(); |
384 | String costMsgContentTemplate = "时间:%s,服务名:%s,IP:%s,超过%dms的请求占比%s,平均耗时:%dms,CPU使用率:%s,可用内存/总内存(MB):%s"; | 390 | String costMsgContentTemplate = "时间:%s,服务名:%s,IP:%s,超过%dms的请求占比%s,平均耗时:%dms,CPU使用率:%s,可用内存/总内存(MB):%s"; |
@@ -18,5 +18,6 @@ redis_exception_mobile=13515100825,18751986615,18652008443,18502542319 | @@ -18,5 +18,6 @@ redis_exception_mobile=13515100825,18751986615,18652008443,18502542319 | ||
18 | java_service_alarm_mobile=18751986615,18652008443,18502542319 | 18 | java_service_alarm_mobile=18751986615,18652008443,18502542319 |
19 | java_service_alarm_flag=true | 19 | java_service_alarm_flag=true |
20 | java_service_alarm_cost_threshold=300 | 20 | java_service_alarm_cost_threshold=300 |
21 | +java_service_alarm_count_threshold=50 | ||
21 | 22 | ||
22 | 23 |
@@ -22,5 +22,6 @@ redis_exception_mobile=15905144483 | @@ -22,5 +22,6 @@ redis_exception_mobile=15905144483 | ||
22 | java_service_alarm_mobile=18614066537 | 22 | java_service_alarm_mobile=18614066537 |
23 | java_service_alarm_flag=true | 23 | java_service_alarm_flag=true |
24 | java_service_alarm_cost_threshold=150 | 24 | java_service_alarm_cost_threshold=150 |
25 | +java_service_alarm_count_threshold=50 | ||
25 | 26 | ||
26 | 27 |
-
Please register or login to post a comment