Merge branch 'wn1020'
Showing
3 changed files
with
10 additions
and
4 deletions
monitor-service-influxdb/src/main/java/com/monitor/influxdb/mapper/impl/ServiceAccessMapperImpl.java
@@ -11,6 +11,8 @@ import org.apache.commons.lang.StringUtils; | @@ -11,6 +11,8 @@ import org.apache.commons.lang.StringUtils; | ||
11 | import org.influxdb.dto.QueryResult; | 11 | import org.influxdb.dto.QueryResult; |
12 | import org.joda.time.DateTime; | 12 | import org.joda.time.DateTime; |
13 | import org.joda.time.DateTimeZone; | 13 | import org.joda.time.DateTimeZone; |
14 | +import org.slf4j.Logger; | ||
15 | +import org.slf4j.LoggerFactory; | ||
14 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
15 | import java.util.*; | 17 | import java.util.*; |
16 | 18 | ||
@@ -25,6 +27,8 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | @@ -25,6 +27,8 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | ||
25 | 27 | ||
26 | private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; | 28 | private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; |
27 | 29 | ||
30 | + Logger log = LoggerFactory.getLogger(ServiceAccessMapperImpl.class); | ||
31 | + | ||
28 | //根据context获取总响应次数和平均耗时 | 32 | //根据context获取总响应次数和平均耗时 |
29 | @Override | 33 | @Override |
30 | public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) { | 34 | public Map<String,NewJavaApiInfoRep> getBaseDataByContext(NewJavaApiInfoReq req) { |
@@ -406,6 +410,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | @@ -406,6 +410,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc | ||
406 | 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); | 410 | 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); |
407 | 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); | 411 | 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); |
408 | String sql = sql1 + sql2; | 412 | String sql = sql1 + sql2; |
413 | + log.info("getAlarmData sql is " + sql); | ||
409 | List<Map> list = new ArrayList<>(); | 414 | List<Map> list = new ArrayList<>(); |
410 | list.addAll(getAlarmData(InfluxDBContants.AWS,sql)); | 415 | list.addAll(getAlarmData(InfluxDBContants.AWS,sql)); |
411 | list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql)); | 416 | list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql)); |
@@ -271,10 +271,10 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S | @@ -271,10 +271,10 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S | ||
271 | 271 | ||
272 | String sql = ""; | 272 | String sql = ""; |
273 | if(req.getServiceType() == -1){ | 273 | if(req.getServiceType() == -1){ |
274 | - sql = String.format("select stack from service_server_exception where %s and hostAddress = '%s' and time > '%s' and time < '%s'",contextFilter,req.getIp(),req.getStartTime(),req.getEndTime()); | 274 | + sql = String.format("select stack from service_server_exception where %s and hostAddress = '%s' and time > '%s' and time < '%s' order by time desc limit 50",contextFilter,req.getIp(),req.getStartTime(),req.getEndTime()); |
275 | 275 | ||
276 | }else{ | 276 | }else{ |
277 | - sql = String.format("select stack from service_server_exception where context='%s' and hostAddress = '%s' and time > '%s' and time < '%s'",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime()); | 277 | + sql = String.format("select stack from service_server_exception where context='%s' and hostAddress = '%s' and time > '%s' and time < '%s' order by time desc limit 50",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime()); |
278 | } | 278 | } |
279 | 279 | ||
280 | String source = ""; | 280 | String source = ""; |
@@ -298,9 +298,9 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S | @@ -298,9 +298,9 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S | ||
298 | } | 298 | } |
299 | 299 | ||
300 | if(StringUtils.isNotBlank(req.getIp())){ | 300 | if(StringUtils.isNotBlank(req.getIp())){ |
301 | - sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and hostAddress = '%s' and event = '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp(),req.getApiName()); | 301 | + sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and hostAddress = '%s' and event = '%s' order by time desc limit 50",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getIp(),req.getApiName()); |
302 | }else{ | 302 | }else{ |
303 | - sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and event = '%s'",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getApiName()); | 303 | + sql = String.format("select stack from service_server_exception where context='%s' and time > '%s' and time < '%s' and event = '%s' order by time desc limit 50",req.getServiceName(),req.getStartTime(),req.getEndTime(),req.getApiName()); |
304 | } | 304 | } |
305 | 305 | ||
306 | return queryErrorInfoList(source,sql); | 306 | return queryErrorInfoList(source,sql); |
@@ -379,6 +379,7 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService { | @@ -379,6 +379,7 @@ public class NewJavaApiInfoServiceImpl implements NewJavaApiInfoService { | ||
379 | costThreshold = 150; | 379 | costThreshold = 150; |
380 | } | 380 | } |
381 | String nowString = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); | 381 | String nowString = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); |
382 | + log.info("sendAlarmMsg nowString is :" + nowString + ",costThreshold is " + costThreshold); | ||
382 | List<Map> list = serviceAccessMapper.getAlarmData(costThreshold); | 383 | List<Map> list = serviceAccessMapper.getAlarmData(costThreshold); |
383 | //获取cpu、内存、带宽使用情况 | 384 | //获取cpu、内存、带宽使用情况 |
384 | Map vmInfoMap = vmInfoMapper.getVMInfo(); | 385 | Map vmInfoMap = vmInfoMapper.getVMInfo(); |
-
Please register or login to post a comment