diff options
| author | gujinkai <[email protected]> | 2023-12-27 15:19:44 +0800 |
|---|---|---|
| committer | gujinkai <[email protected]> | 2023-12-28 14:10:18 +0800 |
| commit | 570772e697b65060595edfae4e705b18d781a2be (patch) | |
| tree | 6ce1787ac08db76c59359f0c9d36308b117a1f4a | |
| parent | c1297cc1a46d4a2f82f51e5005d241294a24344b (diff) | |
feat: adapt to the log change
| -rw-r--r-- | platform-base/src/main/java/com/zdjizhi/base/common/CnRecordLog.java | 2 | ||||
| -rw-r--r-- | platform-etl/src/main/java/com/zdjizhi/etl/utils/CompletedUtils.java | 43 |
2 files changed, 26 insertions, 19 deletions
diff --git a/platform-base/src/main/java/com/zdjizhi/base/common/CnRecordLog.java b/platform-base/src/main/java/com/zdjizhi/base/common/CnRecordLog.java index 5458c53..7c37dc3 100644 --- a/platform-base/src/main/java/com/zdjizhi/base/common/CnRecordLog.java +++ b/platform-base/src/main/java/com/zdjizhi/base/common/CnRecordLog.java @@ -37,7 +37,7 @@ public class CnRecordLog implements Serializable { private String common_app_full_path; @JSONField(name = "decoded_path") private String protocol_path; - @JSONField(serialize = false) + @JSONField(name = "ip_protocol") private String common_l4_protocol; @JSONField(name = "l7_protocol") private String common_l7_protocol; diff --git a/platform-etl/src/main/java/com/zdjizhi/etl/utils/CompletedUtils.java b/platform-etl/src/main/java/com/zdjizhi/etl/utils/CompletedUtils.java index 59f17b3..4a770e6 100644 --- a/platform-etl/src/main/java/com/zdjizhi/etl/utils/CompletedUtils.java +++ b/platform-etl/src/main/java/com/zdjizhi/etl/utils/CompletedUtils.java @@ -35,7 +35,7 @@ public class CompletedUtils { public static void setCompletedMessage(CnRecordLog recordLog) { setDomainAndDomainSld(recordLog); - setl4Protocol(recordLog); + setL4Protocol(recordLog); setl7ProtocolAndApp(recordLog); } @@ -44,38 +44,45 @@ public class CompletedUtils { cnRecordLog.setDomain_sld(cnRecordLog.getServer_domain()); } - private static void setl4Protocol(CnRecordLog cnRecordLog) { - String protocolPath = cnRecordLog.getProtocol_path(); - if (protocolPath != null) { - String[] protocols = cnRecordLog.getProtocol_path().split("\\."); - if (protocols.length > 0) { - String l4Protocol = protocols[protocols.length - 1]; - cnRecordLog.setCommon_l4_protocol(l4Protocol); - } + private static void setL4Protocol(CnRecordLog cnRecordLog) { + if (cnRecordLog.getCommon_l4_protocol() != null) { + cnRecordLog.setCommon_l4_protocol(cnRecordLog.getCommon_l4_protocol().toUpperCase()); } } private static void setl7ProtocolAndApp(CnRecordLog cnRecordLog) { try { + String protocolPath = cnRecordLog.getProtocol_path(); String appFullPath = cnRecordLog.getCommon_app_full_path(); + String fullPath = ""; + int appIndex = 0; + if (protocolPath != null) { + appIndex = protocolPath.split("\\.").length; + fullPath = protocolPath; + } + if (appFullPath != null) { + fullPath = fullPath + "." + appFullPath; + } String l7Protocol = "UNCATEGORIZED"; String app = ""; - if (appFullPath != null) { - appFullPath = appFullPath.toLowerCase(); - String[] split = appFullPath.split("\\."); + if (!"".equals(fullPath)) { + fullPath = fullPath.toLowerCase(); + String[] split = fullPath.split("\\."); int i = 0; - boolean protocolend = false; + boolean protocolEnd = false; while (i < split.length) { String s = split[i]; - boolean isProtocol = false; + boolean isL7Protocol = false; if (l7ProtocolMap.containsKey(s)) { - isProtocol = true; - if (!protocolend) { + isL7Protocol = true; + if (!protocolEnd) { l7Protocol = l7ProtocolMap.get(s); } } - if (!isProtocol) { - protocolend = true; + if (!isL7Protocol && !"UNCATEGORIZED".equals(l7Protocol)) { + protocolEnd = true; + } + if (i >= appIndex && !isL7Protocol) { app = s; } i++; |
