Authored by wangning

update

... ... @@ -40,6 +40,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
}else{
sql = String.format("select count(cost),mean(cost),sum(cost) from service_access where context = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
log.info("getBaseDataByContext sql:" + sql);
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
... ... @@ -77,6 +78,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
}else{
sql = String.format("select count(cost) from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
log.info("getTimeoutCount sql:" + sql);
map.putAll(getTimeoutCount(InfluxDBContants.AWS,sql));
map.putAll(getTimeoutCount(InfluxDBContants.Q_CLOUD,sql));
... ... @@ -106,6 +108,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
public Map<String,List> getJavaApiGraphByServiceType(String context){
Map<String,List> map = new HashMap();
String sql = String.format("SELECT mean(cost) FROM service_access WHERE time > now() - 10m and context = '%s' GROUP BY hostAddress,time(1m) fill(null)",context);
log.info("getJavaApiGraphByServiceType sql:" + sql);
map.putAll(getJavaApiGraphByServiceType(InfluxDBContants.AWS,sql));
map.putAll(getJavaApiGraphByServiceType(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -158,6 +161,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
@Override
public Map<String,List> getServiceNameJavaApiGraph(String source){
String sql = String.format("SELECT mean(cost) FROM service_access WHERE %s and time > now() - 10m GROUP BY context,time(1m) fill(null)",contextFilter);
log.info("getServiceNameJavaApiGraph sql:" + sql);
Map<String,List> resultMap = new HashMap<>();
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
... ... @@ -221,7 +225,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
}
}
log.info("getDataByContextAndIP sql:" + sql);
QueryResult queryResult = query(source, sql, InfluxDBContants.YOHO_EVENT);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
... ... @@ -268,6 +272,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
sql = String.format("select count(cost) from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s' group by event", req.getServiceName(), req.getStartTime(), req.getEndTime());
}
}
log.info("getTimeoutCountByContextAndIp sql:" + sql);
return getTimeoutCountByContextAndIp(source,sql);
}
... ... @@ -295,7 +300,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
String sql = String.format("select count(cost),mean(cost),sum(cost) as sum from service_access where context = '%s' and event = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getApiName(),req.getStartTime(),req.getEndTime());
log.info("getDataByContextAndApiName sql:" + sql);
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -309,6 +314,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
public Map<String,Integer> getTimeoutCountByContextAndApiName(NewJavaApiInfoReq req) {
Map<String,Integer> map = new HashMap();
String sql = String.format("select count(cost) from service_access where context='%s' and event = '%s' and cost > 200 and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getApiName(),req.getStartTime(),req.getEndTime());
log.info("getTimeoutCountByContextAndApiName sql:" + sql);
map.putAll(getTimeoutCount(InfluxDBContants.AWS,sql));
map.putAll(getTimeoutCount(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -324,6 +330,7 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
sql = String.format("select stack from service_access where context='%s' and hostAddress = '%s' and cost > 200 and time > '%s' and time < '%s' order by time desc limit 50",req.getServiceName(),req.getIp(),req.getStartTime(),req.getEndTime());
}
log.info("queryTimeoutInfoListByIp sql:" + sql);
String source = "";
if(req.getCloudType()==2){
source = InfluxDBContants.Q_CLOUD;
... ... @@ -350,6 +357,8 @@ public class ServiceAccessMapperImpl extends InfluxDBQuery implements ServiceAcc
sql = String.format("select stack from service_access where context='%s' and cost > 200 and time > '%s' and time < '%s' and event = '%s' order by time desc limit 50", req.getServiceName(), req.getStartTime(), req.getEndTime(),req.getApiName());
}
log.info("queryTimeoutInfoListByApiName sql:" + sql);
return getTimeoutInfo(source,sql);
}
... ...
... ... @@ -9,6 +9,8 @@ import org.apache.commons.lang.StringUtils;
import org.influxdb.dto.QueryResult;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.*;
... ... @@ -21,7 +23,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
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')";
Logger log = LoggerFactory.getLogger(ServiceServerExceptionMapperImpl.class);
@Override
public Map<String,Integer> getErrorCount(NewJavaApiInfoReq req) {
Map<String,Integer> map = new HashMap();
... ... @@ -31,7 +33,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
}else{
sql = String.format("select count(stack) from service_server_exception where context='%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
log.info("getErrorCount sql:" + sql);
map.putAll(getErrorCount(InfluxDBContants.AWS,sql));
map.putAll(getErrorCount(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -58,6 +60,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
public Map<String,List> getJavaApiGraphByServiceType(String context){
Map<String,List> map = new HashMap();
String sql = String.format("select count(stack) from service_server_exception where context = '%s' and time > now() - 10m GROUP BY hostAddress,time(1m) fill(null)",context);
log.info("getJavaApiGraphByServiceType sql:" + sql);
map.putAll(getJavaApiGraphByServiceType(InfluxDBContants.AWS,sql));
map.putAll(getJavaApiGraphByServiceType(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -109,6 +112,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
public Map<String,List> getServiceNameJavaApiGraph(String source){
Map<String,List> resultMap = new HashMap();
String sql = String.format("select count(stack) from service_server_exception where %s and time > now() - 10m GROUP BY context,time(1m) fill(null)",contextFilter);
log.info("getServiceNameJavaApiGraph sql:" + sql);
QueryResult queryResult = query(source, sql, InfluxDBContants.YOMO_MONITOR);
QueryResult.Result rel = queryResult.getResults().get(0);
List<QueryResult.Series> listSeries = rel.getSeries();
... ... @@ -168,7 +172,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
sql = String.format("select count(stack) from service_server_exception where context='%s' and time > '%s' and time < '%s' group by event",req.getServiceName(),req.getStartTime(),req.getEndTime());
}
}
log.info("getErrorCountByContextAndIp sql:" + sql);
return getErrorCountByContextAndIp(source,sql);
}
... ... @@ -195,6 +199,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
public Map<String,Integer> getErrorCountByContextAndApiName(NewJavaApiInfoReq req) {
Map<String,Integer> map = new HashMap();
String sql = String.format("select count(stack) from service_server_exception where context='%s' and event = '%s' and time > '%s' and time < '%s' group by hostAddress",req.getServiceName(),req.getApiName(),req.getStartTime(),req.getEndTime());
log.info("getErrorCountByContextAndApiName sql:" + sql);
map.putAll(getErrorCount(InfluxDBContants.AWS,sql));
map.putAll(getErrorCount(InfluxDBContants.Q_CLOUD,sql));
return map;
... ... @@ -218,6 +223,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
}else{
source = InfluxDBContants.AWS;
}
log.info("queryErrorInfoListByIp sql:" + sql);
return queryErrorInfoList(source,sql);
}
... ... @@ -237,7 +243,7 @@ public class ServiceServerExceptionMapperImpl extends InfluxDBQuery implements S
}else{
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());
}
log.info("queryErrorInfoListByApiName sql:" + sql);
return queryErrorInfoList(source,sql);
}
... ...
... ... @@ -135,6 +135,7 @@ public class NewJavaApiInfoCtrl {
@RequestMapping("/queryTimeoutInfoListByIp")
@ResponseBody
public BaseResponse queryTimeoutInfoListByIp(@RequestBody NewJavaApiInfoReq req) {
log.info("queryTimeoutInfoListByIp accept pram : {},{},{},{},{},{}",req.getServiceType(),req.getServiceName(),req.getIp(),req.getCloudType(),req.getStartTime(),req.getEndTime());
List<String> list = newJavaApiInfoService.queryTimeoutInfoListByIp(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
... ... @@ -145,6 +146,7 @@ public class NewJavaApiInfoCtrl {
@RequestMapping("/queryTimeoutInfoListByApiName")
@ResponseBody
public BaseResponse queryTimeoutInfoListByApiName(@RequestBody NewJavaApiInfoReq req) {
log.info("queryTimeoutInfoListByApiName accept pram : {},{},{},{},{},{},{}",req.getServiceType(),req.getServiceName(),req.getIp(),req.getCloudType(),req.getStartTime(),req.getEndTime(),req.getApiName());
List<String> list = newJavaApiInfoService.queryTimeoutInfoListByApiName(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
... ... @@ -155,6 +157,7 @@ public class NewJavaApiInfoCtrl {
@RequestMapping("/queryErrorInfoListByIp")
@ResponseBody
public BaseResponse queryErrorInfoListByIp(@RequestBody NewJavaApiInfoReq req) {
log.info("queryErrorInfoListByIp accept pram : {},{},{},{},{},{}",req.getServiceType(),req.getServiceName(),req.getIp(),req.getCloudType(),req.getStartTime(),req.getEndTime());
List<String> list = newJavaApiInfoService.queryErrorInfoListByIp(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
... ... @@ -165,6 +168,7 @@ public class NewJavaApiInfoCtrl {
@RequestMapping("/queryErrorInfoListByApiName")
@ResponseBody
public BaseResponse queryErrorInfoListByApiName(@RequestBody NewJavaApiInfoReq req) {
log.info("queryErrorInfoListByApiName accept pram : {},{},{},{},{},{},{}",req.getServiceType(),req.getServiceName(),req.getIp(),req.getCloudType(),req.getStartTime(),req.getEndTime(),req.getApiName());
List<String> list = newJavaApiInfoService.queryErrorInfoListByApiName(req);
BaseResponse rep = new BaseResponse();
rep.setData(list);
... ... @@ -221,7 +225,7 @@ public class NewJavaApiInfoCtrl {
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Point point = Point.measurement("service_access")
.tag("context","brower").tag("event","/product/new/product/queryProductDetailByProductId").tag("host","/gateway")
.tag("context","gateway").tag("event","/gateway").tag("host","/gateway")
.tag("hostAddress",ip).tag("src_service","app.product.promotion").tag("status_code","200")
.addField("cost", RandomUtils.nextInt(199) + 2000).addField("ip",ip)
.addField("stack","Total Delay [2005ms] /gateway\n +---[2005ms] - com.yoho.core.common.monitor.ThreadProfileInterceptor.preHandle - [enter:1477966424008,exit:1477966426013]\n +---[2005ms] - app.passport.signinAES. - [enter:1477966424008,exit:1477966426013]\n +---[1ms] - com.yoho.core.redis.YHValueOperations.increment - [enter:1477966424008,exit:1477966424009]\n +---[1ms] - com.yoho.core.redis.YHValueOperations.get - [enter:1477966424011,exit:1477966424012]\n +---[2000ms] - com.yoho.core.rest.client.HystrixServiceCaller.usersingle.login - [enter:1477966424012,exit:1477966426012]\n")
... ... @@ -241,7 +245,7 @@ public class NewJavaApiInfoCtrl {
for(int i = 0;i<strs.length;i++){
String ip = strs[i];
Point point = Point.measurement("service_server_exception")
.tag("context","brower").tag("event","/product/new/product/queryProductDetailByProductId").tag("host","/brower/favorite/isFavorite")
.tag("context","gateway").tag("event","/gateway").tag("host","/gateway")
.tag("hostAddress",ip).tag("service_name","brower/favorite/isFavorite")
.addField("ip",ip)
.addField("stack","org.apache.catalina\n.connector.ClientAbortException: java.io.IOException: 断开的管道\n\tat org.apache.catalina.connector.OutputBuffer\n.realWriteBytes(OutputBuffer.java:393)\n\tat org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk\n.java:426)\n\tat org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:342)\n\tat org\n.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:317)\n\tat org.apache.catalina.connector\n.CoyoteOutputStream.flush(CoyoteOutputStream.java:110)\n\tat com.fasterxml.jackson.core.json.UTF8JsonGenerator\n.flush(UTF8JsonGenerator.java:1022)\n\tat com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter\n.java:891)\n\tat org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal\n(AbstractJackson2HttpMessageConverter.java:264)\n\tat org.springframework.http.converter.AbstractGenericHttpMessageConverter\n.write(AbstractGenericHttpMessageConverter.java:100)\n\tat org.springframework.web.servlet.mvc.method\n.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor\n.java:202)\n\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor\n.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:133)\n\tat org.springframework\n.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor\n.java:165)\n\tat org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue\n(HandlerMethodReturnValueHandlerComposite.java:80)\n\tat org.springframework.web.servlet.mvc.method.annotation\n.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)\n\tat org.springframework\n.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter\n.java:806)\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal\n(RequestMappingHandlerAdapter.java:729)\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter\n.handle(AbstractHandlerMethodAdapter.java:85)\n\tat org.springframework.web.servlet.DispatcherServlet\n.doDispatch(DispatcherServlet.java:959)\n\tat org.springframework.web.servlet.DispatcherServlet.doService\n(DispatcherServlet.java:893)\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet\n.java:970)\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)\n\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:648)\n\tat org.springframework.web.servlet\n.FrameworkServlet.service(FrameworkServlet.java:846)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet\n.java:729)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain\n.java:291)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java\n:206)\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\tat org.apache.catalina\n.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)\n\tat org.apache.catalina\n.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n\tat org.springframework.web\n.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)\n\tat org.springframework\n.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\n\tat org.apache.catalina.core\n.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)\n\tat org.apache.catalina.core\n.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)\n\tat org.apache.catalina.core.StandardWrapperValve\n.invoke(StandardWrapperValve.java:217)\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve\n.java:106)\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502\n)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)\n\tat org.apache\n.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)\n\tat org.apache.catalina.core.StandardEngineValve\n.invoke(StandardEngineValve.java:88)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter\n.java:518)\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java\n:1091)\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java\n:673)\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)\n\tat\n org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)\n\tat java.util.concurrent\n.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker\n.run(ThreadPoolExecutor.java:617)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run\n(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:745)\nCaused by: java.io.IOException: 断开\n的管道\n\tat sun.nio.ch.FileDispatcherImpl.write0(Native Method)\n\tat sun.nio.ch.SocketDispatcher.write\n(SocketDispatcher.java:47)\n\tat sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)\n\tat sun.nio\n.ch.IOUtil.write(IOUtil.java:65)\n\tat sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471\n)\n\tat org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:124)\n\tat org.apache.tomcat.util\n.net.NioBlockingSelector.write(NioBlockingSelector.java:101)\n\tat org.apache.tomcat.util.net.NioSelectorPool\n.write(NioSelectorPool.java:172)\n\tat org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket\n(InternalNioOutputBuffer.java:139)\n\tat org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer\n.java:197)\n\tat org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer\n.java:41)\n\tat org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer\n.java:320)\n\tat org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java\n:118)\n\tat org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:256)\n\tat\n org.apache.coyote.Response.doWrite(Response.java:501)\n\tat org.apache.catalina.connector.OutputBuffer\n.realWriteBytes(OutputBuffer.java:388)\n\t... 47 more\n")
... ...