一、日志接口添加查询条件

ntcAppLogs :searchLabelAppId和searchLabelProtoId
ntcBgpLogs :searchAsNum
ntcFtpLogs :searchFtpUrl
ntcP2pLogs :searchP2pFileId和searchP2pKeyword
ntcStreamMediaLogs :searchUrl
ntcVoipLogs :
	searchCallingAccount 和searchCalledAccount;
ntcDdosLogs : searchAttackType
二、修改App活跃IP top100查询接口,添加指标(searchQuota: 1:连接数 2:包数
3:字节数,默认为1),返回数据中添加占比
This commit is contained in:
zhangdongxu
2019-01-08 18:16:05 +08:00
parent 39a86d948b
commit f51120bd33
12 changed files with 212 additions and 24 deletions

View File

@@ -17,4 +17,5 @@ public interface TrafficAppStatisticDao {
List<Map> getAppList(@Param("beginTime")String beginTime,@Param("endTime")String endTime,@Param("appType")Integer[] appType);
List<TrafficAppFocusStatistic> getAppTrend(TrafficAppFocusStatistic entity);
List<AppConnRecordStatistic> appConnRecordTop100(AppConnRecordStatistic entity);
List<AppConnRecordStatistic> appConnRecordTotal(AppConnRecordStatistic entity);
}

View File

@@ -46,24 +46,40 @@
<select id="getAppTrend" parameterType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic" resultType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic">
select stat_time time, max(unique_sip_num) sipNum,max(unique_dip_num) dipNum from traffic_app_focus_statistic t where
<![CDATA[ stat_time>= toDateTime(#{searchStartTime}) and stat_time< toDateTime(#{searchEndTime})
and app_id=toInt64(#{searchAppId}) ]]>
<if test="searchEntranceId">
<![CDATA[and entrance_id=toInt64(#{searchEntranceId}) ]]>
</if>
and app_id=toInt64(#{searchAppId}) and entrance_id=toInt64(#{searchEntranceId}) ]]>
group by stat_time
order by stat_time
</select>
<!-- App通联关系Top100 -->
<!-- App 活跃IP Top100 -->
<select id="appConnRecordTop100" parameterType="com.nis.domain.restful.dashboard.AppConnRecordStatistic" resultType="com.nis.domain.restful.dashboard.AppConnRecordStatistic">
select s_ip ipAddr, sum(c2s_byte_num + s2c_byte_num) byteNum, sum(c2s_pkt_num + s2c_pkt_num) pktNum, count(s_ip) logNum
from tbs_ods_ntc_conn_record_log t where
<![CDATA[ found_time>= toDateTime(#{searchStartTime}) and found_time< toDateTime(#{searchEndTime})
and app_id=toInt64(#{searchAppId}) and entrance_id=toInt64(#{searchEntranceId}) ]]>
group by s_ip
order by
<choose>
<when test="searchQuota !=null and searchQuota != '' and searchQuota == 2 ">
pktNum
</when>
<when test="searchQuota !=null and searchQuota != '' and searchQuota == 3 ">
byteNum
</when>
<otherwise>
logNum
</otherwise>
</choose>
desc limit 100
</select>
<!-- App 所有IP 连接数、包数、字节数 总量统计 用于计算活跃IP Top100的占比情况 -->
<select id="appConnRecordTotal" parameterType="com.nis.domain.restful.dashboard.AppConnRecordStatistic" resultType="com.nis.domain.restful.dashboard.AppConnRecordStatistic">
select sum(c2s_byte_num + s2c_byte_num) byteNum, sum(c2s_pkt_num + s2c_pkt_num) pktNum, count(s_ip) logNum
from tbs_ods_ntc_conn_record_log t where
<![CDATA[ found_time>= toDateTime(#{searchStartTime}) and found_time< toDateTime(#{searchEndTime})
and app_id=toInt64(#{searchAppId}) ]]>
<if test="searchEntranceId">
<if test="searchEntranceId !=null and searchEntranceId != ''">
<![CDATA[and entrance_id=toInt64(#{searchEntranceId}) ]]>
</if>
group by s_ip
order by logNum desc limit 100
</select>
</mapper>

View File

@@ -250,7 +250,7 @@ public class LogDataService {
String field = filedAndColumnMap.get(key).toLowerCase();
if (type.equals("java.lang.String")) {
if (field.equals("url") || field.equals("website")) {
if (field.contains("url") || field.equals("website")) {
whereSB.append(" and " + field + " like '"
+ StringEscapeUtils.unescapeHtml4(value.toString().trim()) + "%'");
} else if (field.equals("client_locate") || field.equals("server_locate")) {
@@ -407,7 +407,7 @@ public class LogDataService {
if (typeName.equals("java.lang.String")) {
String field = filedAndColumnMap.get(key);
if (field.equals("url") || field.equals("website")) {
if (field.contains("url") || field.equals("website")) {
whereSB.append(" and " + field + " like '"
+ StringEscapeUtils.unescapeHtml4(value.toString().trim()) + "%'");
} else {

View File

@@ -1,5 +1,6 @@
package com.nis.web.service.restful;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -15,6 +16,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -565,7 +567,7 @@ public class DashboardService extends BaseService {
int index = 0;
for (int i = 0; i < dateRangeList.size(); i++) {
// 存放一个时间点中每个IP的总数
Map<String, Long> ipCountMap = new HashMap<String, Long>();
Map<String, Long> ipCountMap = new TreeMap<String, Long>();
Date date = dateRangeList.get(i);
for (int j = index; j < ipInfoList.size(); j++) {
TrafficIpActiveStatistic ipInfo = ipInfoList.get(j);
@@ -1695,8 +1697,18 @@ public class DashboardService extends BaseService {
}
public List<AppConnRecordStatistic> appConnRecordTop100(AppConnRecordStatistic entity) {
DecimalFormat df = new DecimalFormat("##.##");
List<AppConnRecordStatistic> list = new ArrayList<AppConnRecordStatistic>();
list = trafficAppStatisticDao.appConnRecordTop100(entity);
if (!StringUtil.isEmpty(list)) {
//统计总量
AppConnRecordStatistic sum = trafficAppStatisticDao.appConnRecordTotal(entity).get(0);
for (AppConnRecordStatistic obj : list) {
obj.setBytePercent(df.format(obj.getByteNum()/sum.getByteNum()*100));
obj.setPktPercent(df.format(obj.getPktNum()/sum.getPktNum()*100));
obj.setLogPercent(df.format(obj.getLogNum()/sum.getLogNum()*100));
}
}
return list;
}
}