add detect type for usad model.

(cherry picked from commit 8824edf123e5f434d8aa1f22d260935f400728d5)
This commit is contained in:
huangbin 2024-11-27 18:55:25 +08:00 committed by openeuler-sync-bot
parent 7afcfbcb53
commit 52bdd06c00
2 changed files with 74 additions and 1 deletions

View File

@ -0,0 +1,69 @@
From d5b616b2d835ded5abbecc23281be1b0eb2cf3e4 Mon Sep 17 00:00:00 2001
From: huangbin <huangbin58@huawei.com>
Date: Wed, 27 Nov 2024 17:32:45 +0800
Subject: [PATCH] add detect type for usad model
---
anteater/model/detector/usad_detector.py | 19 ++++++++++++-------
config/module/usad_model.job.json | 3 ++-
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/anteater/model/detector/usad_detector.py b/anteater/model/detector/usad_detector.py
index 567a77c..142ccef 100644
--- a/anteater/model/detector/usad_detector.py
+++ b/anteater/model/detector/usad_detector.py
@@ -62,6 +62,7 @@ class UsadDetector(Detector):
self.cause_list = None
self.candidates = {}
self.machine_training = {}
+ self.detect_type = config.params.get("detect_type", "machine")
def detect_machine_kpis(self, kpis: List[KPI], features: List[Feature], machine_id, key):
"""Executes anomaly detection on kpis"""
@@ -301,13 +302,17 @@ class UsadDetector(Detector):
entity_ids = []
entity_keys = []
- # machine_ids = self.data_loader.get_unique_machines(start, end, metrics)
- # entity_keys.extend(['machine_id'] * len(machine_ids))
- # entity_ids.extend(machine_ids)
-
- pod_ids = self.data_loader.get_unique_pods(start, end, metrics)
- entity_keys.extend(['pod_id'] * len(pod_ids))
- entity_ids.extend(pod_ids)
+
+ if self.detect_type == "machine":
+ # machine
+ machine_ids = self.data_loader.get_unique_machines(start, end, metrics)
+ entity_keys.extend(['machine_id'] * len(machine_ids))
+ entity_ids.extend(machine_ids)
+ else:
+ # pod
+ pod_ids = self.data_loader.get_unique_pods(start, end, metrics)
+ entity_keys.extend(['pod_id'] * len(pod_ids))
+ entity_ids.extend(pod_ids)
if not entity_ids:
logger.warning('Empty entity_ids, RETURN!')
diff --git a/config/module/usad_model.job.json b/config/module/usad_model.job.json
index a3ff4e6..54bb32c 100644
--- a/config/module/usad_model.job.json
+++ b/config/module/usad_model.job.json
@@ -73,6 +73,7 @@
"model_config": {
"name": "usad_model",
"params": {
+ "detect_type": "machine",
"th": 0.5,
"max_error_rate": 0.7,
"min_train_hours": 12,
@@ -419,4 +420,4 @@
"metric": "gala_gopher_nic_tc_sent_drop"
}
]
-}
\ No newline at end of file
+}
--
2.43.0

View File

@ -2,7 +2,7 @@
Name: gala-anteater
Version: 1.2.1
Release: 5
Release: 6
Summary: A time-series anomaly detection platform for operating system.
License: MulanPSL2
URL: https://gitee.com/openeuler/gala-anteater
@ -15,6 +15,7 @@ patch0: 0001-add-new-feature-slow-node-detection.patch
patch1: 0002-configure-group-in-json.patch
patch2: 0003-remove-unuse-code.patch
patch3: 0004-fixbug-wrong-label-for-dbscan.patch
patch4: 0005-add-detect-type-for-usad-model.patch
%description
Abnormal detection module for A-Ops project
@ -82,6 +83,9 @@ fi
%changelog
* Wed Nov 27 2024 huangbin <huangbin58@huawei.com> - 1.2.1-6
- add detect type for usad model.
* Thu Nov 21 2024 huangbin <huangbin58@huawei.com> - 1.2.1-5
- fixbug with wrong label in dbscan.