64 lines
2.7 KiB
Diff
64 lines
2.7 KiB
Diff
From 36de2919c2d9f6ea3bc893ec7d0e72750b1e4805 Mon Sep 17 00:00:00 2001
|
|
From: zhu-yuncheng <zhuyuncheng@huawei.com>
|
|
Date: Thu, 8 Dec 2022 22:01:31 +0800
|
|
Subject: [PATCH] better ai model logic and fix count alert error
|
|
|
|
---
|
|
.../experiment/algorithm/multi_item_check/intelligent.py | 8 +++++++-
|
|
diana/core/rule/workflow.py | 2 +-
|
|
diana/database/dao/result_dao.py | 3 +--
|
|
3 files changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/diana/core/experiment/algorithm/multi_item_check/intelligent.py b/diana/core/experiment/algorithm/multi_item_check/intelligent.py
|
|
index fc4b223..c96f011 100644
|
|
--- a/diana/core/experiment/algorithm/multi_item_check/intelligent.py
|
|
+++ b/diana/core/experiment/algorithm/multi_item_check/intelligent.py
|
|
@@ -125,7 +125,13 @@ class Intelligent(BaseMultiItemAlgorithmTwo):
|
|
if fusion_strategy == 'intersection':
|
|
for column in concat_result.columns:
|
|
concat_result['total'] = concat_result['total'] & concat_result[column]
|
|
- if concat_result[concat_result['total'] == True].shape[0] > 0:
|
|
+
|
|
+ time = pd.to_datetime(time_range[1] - 600, unit='s')
|
|
+ index = concat_result.index
|
|
+ select_index = index[index > time]
|
|
+ select_result = concat_result.loc[select_index]
|
|
+
|
|
+ if select_result[select_result['total'] == True].shape[0] > 0:
|
|
return True
|
|
|
|
return False
|
|
diff --git a/diana/core/rule/workflow.py b/diana/core/rule/workflow.py
|
|
index 475378e..47df2f8 100644
|
|
--- a/diana/core/rule/workflow.py
|
|
+++ b/diana/core/rule/workflow.py
|
|
@@ -205,7 +205,7 @@ class Workflow:
|
|
return DATABASE_CONNECT_ERROR
|
|
|
|
# data time range should based on the algorithm in the future
|
|
- data_time_range = [time_range[1]-900, time_range[1]]
|
|
+ data_time_range = [time_range[1]-1500, time_range[1]]
|
|
data_status, monitor_data = data_dao.query_data(
|
|
time_range=data_time_range, host_list=hosts)
|
|
|
|
diff --git a/diana/database/dao/result_dao.py b/diana/database/dao/result_dao.py
|
|
index 347e2c5..45428d6 100644
|
|
--- a/diana/database/dao/result_dao.py
|
|
+++ b/diana/database/dao/result_dao.py
|
|
@@ -306,11 +306,10 @@ class ResultDao(MysqlProxy):
|
|
try:
|
|
fliters = {
|
|
DomainCheckResult.username == data['username'],
|
|
- DomainCheckResult.alert_id == AlertHost.alert_id,
|
|
DomainCheckResult.confirmed == 0
|
|
}
|
|
alert_count_query = self.session.query(
|
|
- func.count(AlertHost.alert_id)).filter(*fliters).scalar()
|
|
+ func.count(DomainCheckResult.alert_id)).filter(*fliters).scalar()
|
|
|
|
except SQLAlchemyError as error:
|
|
LOGGER.error(error)
|
|
--
|
|
2.33.0
|
|
|