...
|
...
|
@@ -25,7 +25,7 @@ import java.util.*; |
|
|
public class ServiceAccessMapperImpl implements ServiceAccessMapper {
|
|
|
|
|
|
@Autowired
|
|
|
private InfluxDataReporter commonQuery;
|
|
|
private InfluxDataReporter influxDataReporter;
|
|
|
|
|
|
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')";
|
|
|
|
...
|
...
|
@@ -44,7 +44,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
}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);
|
|
|
// log.info("getBaseDataByContext sql:" + sql);
|
|
|
|
|
|
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
|
...
|
...
|
@@ -53,7 +53,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
|
|
|
private Map<String,NewJavaApiInfoRep> getDataByContext(String source,String sql) {
|
|
|
Map<String,NewJavaApiInfoRep> map = new HashMap<>();
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -82,7 +82,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
}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);
|
|
|
// log.info("getTimeoutCount sql:" + sql);
|
|
|
|
|
|
map.putAll(getTimeoutCount(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getTimeoutCount(InfluxDBContants.Q_CLOUD,sql));
|
...
|
...
|
@@ -91,7 +91,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
|
|
|
private Map<String,Integer> getTimeoutCount(String source,String sql) {
|
|
|
Map<String,Integer> map = new HashMap<>();
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -112,7 +112,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
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);
|
|
|
// log.info("getJavaApiGraphByServiceType sql:" + sql);
|
|
|
map.putAll(getJavaApiGraphByServiceType(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getJavaApiGraphByServiceType(InfluxDBContants.Q_CLOUD,sql));
|
|
|
return map;
|
...
|
...
|
@@ -122,7 +122,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
private Map<String,List> getJavaApiGraphByServiceType(String source,String sql) {
|
|
|
Map<String,List> resultMap = new HashMap<>();
|
|
|
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -165,10 +165,10 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
@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);
|
|
|
// log.info("getServiceNameJavaApiGraph sql:" + sql);
|
|
|
Map<String,List> resultMap = new HashMap<>();
|
|
|
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -229,8 +229,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
}
|
|
|
}
|
|
|
|
|
|
log.info("getDataByContextAndIP sql:" + sql);
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -284,7 +283,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
|
|
|
private Map<String,Integer> getTimeoutCountByContextAndIp(String source,String sql) {
|
|
|
Map<String,Integer> map = new HashMap<>();
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -304,7 +303,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
|
|
|
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);
|
|
|
// log.info("getDataByContextAndApiName sql:" + sql);
|
|
|
map.putAll(getDataByContext(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getDataByContext(InfluxDBContants.Q_CLOUD,sql));
|
|
|
return map;
|
...
|
...
|
@@ -318,7 +317,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
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);
|
|
|
// log.info("getTimeoutCountByContextAndApiName sql:" + sql);
|
|
|
map.putAll(getTimeoutCount(InfluxDBContants.AWS,sql));
|
|
|
map.putAll(getTimeoutCount(InfluxDBContants.Q_CLOUD,sql));
|
|
|
return map;
|
...
|
...
|
@@ -368,7 +367,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
|
|
|
private List<String> getTimeoutInfo(String source,String sql) {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel = queryResult.getResults().get(0);
|
|
|
List<QueryResult.Series> listSeries = rel.getSeries();
|
|
|
if(listSeries == null)
|
...
|
...
|
@@ -394,7 +393,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
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);
|
|
|
// log.info("getAlarmData sql is " + sql);
|
|
|
List<Map> list = new ArrayList<>();
|
|
|
list.addAll(getAlarmData(InfluxDBContants.AWS,sql,countThreshold));
|
|
|
list.addAll(getAlarmData(InfluxDBContants.Q_CLOUD,sql,countThreshold));
|
...
|
...
|
@@ -404,7 +403,7 @@ public class ServiceAccessMapperImpl implements ServiceAccessMapper { |
|
|
private List<Map> getAlarmData(String source,String sql,Integer countThreshold){
|
|
|
|
|
|
List<Map> returnList = new ArrayList<>();
|
|
|
QueryResult queryResult = commonQuery.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult queryResult = influxDataReporter.queryResult(source, sql, InfluxDBContants.YOHO_EVENT);
|
|
|
QueryResult.Result rel1 = queryResult.getResults().get(0);
|
|
|
QueryResult.Result rel2 = queryResult.getResults().get(1);
|
|
|
List<QueryResult.Series> listSeries1 = rel1.getSeries();
|
...
|
...
|
|