Adaptation for abnormal event output change
This commit is contained in:
parent
67be795592
commit
42f559bc94
108
0002-adaptation-for-abnormal-event-output-change.patch
Normal file
108
0002-adaptation-for-abnormal-event-output-change.patch
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
From 8a89c59b0c6194afdd6ed1c9bbd949b2cc62aeb0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: algorithmofdish <hexiujun1@huawei.com>
|
||||||
|
Date: Tue, 29 Nov 2022 17:07:12 +0800
|
||||||
|
Subject: [PATCH] refactor(infer): adaptation for abnormal event output change
|
||||||
|
|
||||||
|
---
|
||||||
|
cause_inference/__main__.py | 25 +++++++++++++++++++++----
|
||||||
|
cause_inference/cause_infer.py | 21 ---------------------
|
||||||
|
2 files changed, 21 insertions(+), 25 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/cause_inference/__main__.py b/cause_inference/__main__.py
|
||||||
|
index 093f7ac..d586b1f 100644
|
||||||
|
--- a/cause_inference/__main__.py
|
||||||
|
+++ b/cause_inference/__main__.py
|
||||||
|
@@ -14,7 +14,6 @@ from cause_inference.config import infer_config
|
||||||
|
from cause_inference.config import init_infer_config
|
||||||
|
from cause_inference.model import AbnormalEvent
|
||||||
|
from cause_inference.cause_infer import cause_locating
|
||||||
|
-from cause_inference.cause_infer import parse_abn_evt
|
||||||
|
from cause_inference.cause_infer import preprocess_abn_score
|
||||||
|
from cause_inference.rule_parser import rule_engine
|
||||||
|
from cause_inference.exceptions import InferenceException
|
||||||
|
@@ -164,16 +163,34 @@ def init_obsv_meta_coll_thd():
|
||||||
|
return obsv_meta_coll_thread
|
||||||
|
|
||||||
|
|
||||||
|
+def parse_abn_evt(data) -> AbnormalEvent:
|
||||||
|
+ resource = data.get('Resource', {})
|
||||||
|
+ attrs = data.get('Attributes', {})
|
||||||
|
+ if not resource.get('metric'):
|
||||||
|
+ raise DataParseException('Attribute "Resource.metric" required in abnormal event')
|
||||||
|
+ if not attrs.get('entity_id') and not resource.get('labels'):
|
||||||
|
+ raise DataParseException('metric_label or entity_id info need in abnormal event')
|
||||||
|
+ abn_evt = AbnormalEvent(
|
||||||
|
+ timestamp=data.get('Timestamp'),
|
||||||
|
+ abnormal_metric_id=resource.get('metric'),
|
||||||
|
+ abnormal_score=preprocess_abn_score(resource.get('score', 0.0)),
|
||||||
|
+ metric_labels=resource.get('labels'),
|
||||||
|
+ abnormal_entity_id=attrs.get('entity_id'),
|
||||||
|
+ desc=resource.get('description', '') or data.get('Body', '')
|
||||||
|
+ )
|
||||||
|
+ return abn_evt
|
||||||
|
+
|
||||||
|
+
|
||||||
|
def get_recommend_metric_evts(abn_kpi_data: dict) -> List[AbnormalEvent]:
|
||||||
|
metric_evts = []
|
||||||
|
obsv_meta_mgt = ObserveMetaMgt()
|
||||||
|
- recommend_metrics = abn_kpi_data.get('Resource', {}).get('recommend_metrics', {})
|
||||||
|
+ recommend_metrics = abn_kpi_data.get('Resource', {}).get('cause_metrics', {})
|
||||||
|
for metric_data in recommend_metrics:
|
||||||
|
metric_evt = AbnormalEvent(
|
||||||
|
timestamp=abn_kpi_data.get('Timestamp'),
|
||||||
|
abnormal_metric_id=metric_data.get('metric', ''),
|
||||||
|
- abnormal_score=preprocess_abn_score(metric_data.get('score')),
|
||||||
|
- metric_labels=metric_data.get('label', {}),
|
||||||
|
+ abnormal_score=preprocess_abn_score(metric_data.get('score', 0.0)),
|
||||||
|
+ metric_labels=metric_data.get('labels', {}),
|
||||||
|
desc=metric_data.get('description', '')
|
||||||
|
)
|
||||||
|
if not metric_evt.update_entity_id(obsv_meta_mgt):
|
||||||
|
diff --git a/cause_inference/cause_infer.py b/cause_inference/cause_infer.py
|
||||||
|
index dff26d0..6873c1e 100644
|
||||||
|
--- a/cause_inference/cause_infer.py
|
||||||
|
+++ b/cause_inference/cause_infer.py
|
||||||
|
@@ -1,7 +1,5 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
-from scipy.special import expit
|
||||||
|
-
|
||||||
|
from cause_inference.model import Cause
|
||||||
|
from cause_inference.model import CausalGraph
|
||||||
|
from cause_inference.model import AbnormalEvent
|
||||||
|
@@ -12,7 +10,6 @@ from spider.collector.data_collector import DataCollector
|
||||||
|
from spider.collector.prometheus_collector import PrometheusCollector
|
||||||
|
from cause_inference.exceptions import InferenceException
|
||||||
|
from cause_inference.exceptions import DBException
|
||||||
|
-from cause_inference.exceptions import DataParseException
|
||||||
|
from cause_inference.config import infer_config
|
||||||
|
from cause_inference.rule_parser import rule_engine
|
||||||
|
from cause_inference.arangodb import connect_to_arangodb
|
||||||
|
@@ -68,24 +65,6 @@ def query_abnormal_topo_subgraph(abnormal_event: AbnormalEvent):
|
||||||
|
return subgraph
|
||||||
|
|
||||||
|
|
||||||
|
-def parse_abn_evt(data) -> AbnormalEvent:
|
||||||
|
- resource = data.get('Resource', {})
|
||||||
|
- attrs = data.get('Attributes', {})
|
||||||
|
- if not resource.get('metrics'):
|
||||||
|
- raise DataParseException('Atribute "Resource.metrics" required in abnormal event')
|
||||||
|
- if not attrs.get('entity_id') and not resource.get('metric_label'):
|
||||||
|
- raise DataParseException('metric_label or entity_id info need in abnormal event')
|
||||||
|
- abn_evt = AbnormalEvent(
|
||||||
|
- timestamp=data.get('Timestamp'),
|
||||||
|
- abnormal_metric_id=resource.get('metrics'),
|
||||||
|
- abnormal_score=1.0,
|
||||||
|
- metric_labels=resource.get('metric_label'),
|
||||||
|
- abnormal_entity_id=attrs.get('entity_id'),
|
||||||
|
- desc=resource.get('description', '') or data.get('Body', '')
|
||||||
|
- )
|
||||||
|
- return abn_evt
|
||||||
|
-
|
||||||
|
-
|
||||||
|
def parse_entity_id(orig_entity_id: str) -> str:
|
||||||
|
fs_idx = orig_entity_id.index('/')
|
||||||
|
return orig_entity_id[fs_idx+1:]
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Name: gala-spider
|
Name: gala-spider
|
||||||
Version: 1.0.0
|
Version: 1.0.0
|
||||||
Release: 5
|
Release: 6
|
||||||
Summary: OS topological graph storage service and cause inference service for gala-ops project
|
Summary: OS topological graph storage service and cause inference service for gala-ops project
|
||||||
License: MulanPSL2
|
License: MulanPSL2
|
||||||
URL: https://gitee.com/openeuler/gala-spider
|
URL: https://gitee.com/openeuler/gala-spider
|
||||||
@ -12,6 +12,7 @@ BuildRequires: python3-setuptools systemd
|
|||||||
Requires: python3-%{name} = %{version}-%{release}
|
Requires: python3-%{name} = %{version}-%{release}
|
||||||
|
|
||||||
patch0: 0001-cause-inference-optimization.patch
|
patch0: 0001-cause-inference-optimization.patch
|
||||||
|
patch1: 0002-adaptation-for-abnormal-event-output-change.patch
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -123,6 +124,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Dec 10 2022 algorithmofdish <hexiujun1@huawei.com> - 1.0.0-6
|
||||||
|
- Adaptation for abnormal event output change
|
||||||
|
|
||||||
* Tue Dec 6 2022 Zhen Chen <chenzhen126@huawei.com> - 1.0.0-5
|
* Tue Dec 6 2022 Zhen Chen <chenzhen126@huawei.com> - 1.0.0-5
|
||||||
- Provide gala-ops package to install anteater/spider/inference at once
|
- Provide gala-ops package to install anteater/spider/inference at once
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user