删除metric指标client_ip_sketch。(TSG-17949)
新增job name配置。
This commit is contained in:
@@ -3,11 +3,6 @@ package com.zdjizhi.utils.general;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.zdjizhi.common.pojo.Fields;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
import org.apache.datasketches.hll.HllSketch;
|
||||
import org.apache.datasketches.hll.Union;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,45 +22,33 @@ public class MetricUtil {
|
||||
*/
|
||||
public static Fields statisticsMetrics(Fields cacheData, Fields newData) {
|
||||
|
||||
Long sessions = MetricUtil.longSum(cacheData.getSessions(), newData.getSessions());
|
||||
long sessions = MetricUtil.longSum(cacheData.getSessions(), newData.getSessions());
|
||||
|
||||
Long inBytes = MetricUtil.longSum(cacheData.getIn_bytes(), newData.getIn_bytes());
|
||||
Long outBytes = MetricUtil.longSum(cacheData.getOut_bytes(), newData.getOut_bytes());
|
||||
Long inPkts = MetricUtil.longSum(cacheData.getIn_pkts(), newData.getIn_pkts());
|
||||
Long outPkts = MetricUtil.longSum(cacheData.getOut_pkts(), newData.getOut_pkts());
|
||||
long inBytes = MetricUtil.longSum(cacheData.getIn_bytes(), newData.getIn_bytes());
|
||||
long outBytes = MetricUtil.longSum(cacheData.getOut_bytes(), newData.getOut_bytes());
|
||||
long inPkts = MetricUtil.longSum(cacheData.getIn_pkts(), newData.getIn_pkts());
|
||||
long outPkts = MetricUtil.longSum(cacheData.getOut_pkts(), newData.getOut_pkts());
|
||||
|
||||
|
||||
Long c2sBytes = MetricUtil.longSum(cacheData.getC2s_bytes(), newData.getC2s_bytes());
|
||||
Long s2cBytes = MetricUtil.longSum(cacheData.getS2c_bytes(), newData.getS2c_bytes());
|
||||
Long c2sPkts = MetricUtil.longSum(cacheData.getC2s_pkts(), newData.getC2s_pkts());
|
||||
Long s2cPkts = MetricUtil.longSum(cacheData.getS2c_pkts(), newData.getS2c_pkts());
|
||||
long c2sBytes = MetricUtil.longSum(cacheData.getC2s_bytes(), newData.getC2s_bytes());
|
||||
long s2cBytes = MetricUtil.longSum(cacheData.getS2c_bytes(), newData.getS2c_bytes());
|
||||
long c2sPkts = MetricUtil.longSum(cacheData.getC2s_pkts(), newData.getC2s_pkts());
|
||||
long s2cPkts = MetricUtil.longSum(cacheData.getS2c_pkts(), newData.getS2c_pkts());
|
||||
|
||||
Long c2sFragments = MetricUtil.longSum(cacheData.getC2s_fragments(), newData.getC2s_fragments());
|
||||
Long s2cFragments = MetricUtil.longSum(cacheData.getS2c_fragments(), newData.getS2c_fragments());
|
||||
long c2sFragments = MetricUtil.longSum(cacheData.getC2s_fragments(), newData.getC2s_fragments());
|
||||
long s2cFragments = MetricUtil.longSum(cacheData.getS2c_fragments(), newData.getS2c_fragments());
|
||||
|
||||
Long c2sTcpLostBytes = MetricUtil.longSum(cacheData.getC2s_tcp_lost_bytes(), newData.getC2s_tcp_lost_bytes());
|
||||
Long s2cTcpLostBytes = MetricUtil.longSum(cacheData.getS2c_tcp_lost_bytes(), newData.getS2c_tcp_lost_bytes());
|
||||
long c2sTcpLostBytes = MetricUtil.longSum(cacheData.getC2s_tcp_lost_bytes(), newData.getC2s_tcp_lost_bytes());
|
||||
long s2cTcpLostBytes = MetricUtil.longSum(cacheData.getS2c_tcp_lost_bytes(), newData.getS2c_tcp_lost_bytes());
|
||||
|
||||
Long c2sTcpooorderPkts = MetricUtil.longSum(cacheData.getC2s_tcp_ooorder_pkts(), newData.getC2s_tcp_ooorder_pkts());
|
||||
Long s2cTcpooorderPkts = MetricUtil.longSum(cacheData.getS2c_tcp_ooorder_pkts(), newData.getS2c_tcp_ooorder_pkts());
|
||||
long c2sTcpooorderPkts = MetricUtil.longSum(cacheData.getC2s_tcp_ooorder_pkts(), newData.getC2s_tcp_ooorder_pkts());
|
||||
long s2cTcpooorderPkts = MetricUtil.longSum(cacheData.getS2c_tcp_ooorder_pkts(), newData.getS2c_tcp_ooorder_pkts());
|
||||
|
||||
Long c2sTcpretransmittedPkts = MetricUtil.longSum(cacheData.getC2s_tcp_retransmitted_pkts(), newData.getC2s_tcp_retransmitted_pkts());
|
||||
Long s2cTcpretransmittedPkts = MetricUtil.longSum(cacheData.getS2c_tcp_retransmitted_pkts(), newData.getS2c_tcp_retransmitted_pkts());
|
||||
long c2sTcpretransmittedPkts = MetricUtil.longSum(cacheData.getC2s_tcp_retransmitted_pkts(), newData.getC2s_tcp_retransmitted_pkts());
|
||||
long s2cTcpretransmittedPkts = MetricUtil.longSum(cacheData.getS2c_tcp_retransmitted_pkts(), newData.getS2c_tcp_retransmitted_pkts());
|
||||
|
||||
Long c2sTcpretransmittedBytes = MetricUtil.longSum(cacheData.getC2s_tcp_retransmitted_bytes(), newData.getC2s_tcp_retransmitted_bytes());
|
||||
Long s2cTcpretransmittedBytes = MetricUtil.longSum(cacheData.getS2c_tcp_retransmitted_bytes(), newData.getS2c_tcp_retransmitted_bytes());
|
||||
|
||||
|
||||
// String clientIpSketch = MetricUtil.hllSketchUnion(cacheData.getClient_ip_sketch(), newData.getClient_ip_sketch());
|
||||
// return new Fields(sessions,
|
||||
// inBytes, outBytes, inPkts, outPkts,
|
||||
// c2sPkts, s2cPkts, c2sBytes, s2cBytes,
|
||||
// c2sFragments, s2cFragments,
|
||||
// c2sTcpLostBytes, s2cTcpLostBytes,
|
||||
// c2sTcpooorderPkts, s2cTcpooorderPkts,
|
||||
// c2sTcpretransmittedPkts, s2cTcpretransmittedPkts,
|
||||
// c2sTcpretransmittedBytes, s2cTcpretransmittedBytes,
|
||||
// clientIpSketch);
|
||||
long c2sTcpretransmittedBytes = MetricUtil.longSum(cacheData.getC2s_tcp_retransmitted_bytes(), newData.getC2s_tcp_retransmitted_bytes());
|
||||
long s2cTcpretransmittedBytes = MetricUtil.longSum(cacheData.getS2c_tcp_retransmitted_bytes(), newData.getS2c_tcp_retransmitted_bytes());
|
||||
|
||||
return new Fields(sessions,
|
||||
inBytes, outBytes, inPkts, outPkts,
|
||||
@@ -74,20 +57,19 @@ public class MetricUtil {
|
||||
c2sTcpLostBytes, s2cTcpLostBytes,
|
||||
c2sTcpooorderPkts, s2cTcpooorderPkts,
|
||||
c2sTcpretransmittedPkts, s2cTcpretransmittedPkts,
|
||||
c2sTcpretransmittedBytes, s2cTcpretransmittedBytes,
|
||||
null);
|
||||
c2sTcpretransmittedBytes, s2cTcpretransmittedBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Long类型的数据求和
|
||||
*
|
||||
* @param cacheData 缓存中的值
|
||||
* @param newData 新来数据的值
|
||||
* @param newData 新来数据的值
|
||||
* @return cacheData + newData
|
||||
*/
|
||||
private static Long longSum(Long cacheData, Long newData) {
|
||||
private static long longSum(long cacheData, long newData) {
|
||||
|
||||
Long result;
|
||||
long result;
|
||||
try {
|
||||
if (cacheData >= 0 && newData >= 0) {
|
||||
result = cacheData + newData;
|
||||
@@ -95,38 +77,11 @@ public class MetricUtil {
|
||||
result = cacheData;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("Abnormal sending of traffic indicator statistics! The message is:{}" , e);
|
||||
logger.error("Abnormal sending of traffic indicator statistics! The message is:{}", e);
|
||||
result = cacheData;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cacheHll 缓存的sketch
|
||||
* @param newHll 聚合后的sketch
|
||||
* @return 合并后的sketch
|
||||
*/
|
||||
private static String hllSketchUnion(String cacheHll, String newHll) {
|
||||
Union union = new Union(12);
|
||||
try {
|
||||
if (StringUtil.isNotBlank(cacheHll)) {
|
||||
byte[] cacheHllBytes = Base64.getDecoder().decode(cacheHll);
|
||||
HllSketch cacheSketch = HllSketch.heapify(cacheHllBytes);
|
||||
union.update(cacheSketch);
|
||||
}
|
||||
|
||||
if (StringUtil.isNotBlank(newHll)) {
|
||||
byte[] newHllBytes = Base64.getDecoder().decode(newHll);
|
||||
HllSketch newSketch = HllSketch.heapify(newHllBytes);
|
||||
union.update(newSketch);
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(union.getResult().toUpdatableByteArray());
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("Merge hllSketch results abnormal! The message is:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user