From 06b710d09c1f60a2847b1605534b95fd905a2964 Mon Sep 17 00:00:00 2001 From: jinsol24 Date: Fri, 14 Nov 2025 13:12:33 +0900 Subject: [PATCH] modify for slack alarm --- main.py | 9 +++++---- src/es_client.py | 2 +- src/feature_engineering.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 36b9bb6..5920810 100644 --- a/main.py +++ b/main.py @@ -61,6 +61,7 @@ def save_grouped_events_to_es(es_client, docs_to_save, target_index): print(f"Elasticsearch Bulk 저장 중 오류 발생: {e}") if hasattr(e, 'errors'): print(f"상세 오류: {e.errors}") + raise e def get_next_group_id_offset(es_client, index_pattern="planit-edr-ai-grouping-*"): """ @@ -138,10 +139,10 @@ def run_inference(es_host, es_user, es_pass, target_index_date_str): except FileNotFoundError as e: print(f"오류: 필수 파일 없음: {e}") - return + raise e except Exception as e: print(f"아티팩트 로드 중 오류: {e}") - return + raise e # --- 2. Elasticsearch 연결 및 데이터 로드 (함수 호출) --- try: @@ -163,7 +164,7 @@ def run_inference(es_host, es_user, es_pass, target_index_date_str): except Exception as e: print(f"Elasticsearch 연결 중 오류: {e}") - return + raise e # --- 3. 피처 엔지니어링 (함수 호출) --- # (src.feature_engineering에서 함수 가져옴) @@ -219,7 +220,7 @@ def run_inference(es_host, es_user, es_pass, target_index_date_str): current_global_offset = get_next_group_id_offset(es_client, f"planit-edr-ai-grouping-*") except Exception as e: print(f"오류: 그룹 ID 오프셋 조회 실패. {e}") - return + raise e # 5-4. Host별 반복문 돌며 클러스터링 수행 print(f"총 {len(host_groups)}개의 Host에 대해 개별 클러스터링 수행 중...") diff --git a/src/es_client.py b/src/es_client.py index ebd68d9..85b5f29 100644 --- a/src/es_client.py +++ b/src/es_client.py @@ -61,4 +61,4 @@ def fetch_malicious_events(es_client, preprocessors, target_index_date_str): return None, None print(f"Elasticsearch 데이터 로드 중 오류: {e}") - return None, None \ No newline at end of file + raise e \ No newline at end of file diff --git a/src/feature_engineering.py b/src/feature_engineering.py index 8c92456..0fe3659 100644 --- a/src/feature_engineering.py +++ b/src/feature_engineering.py @@ -167,7 +167,7 @@ def feature_engineer_inference(df, preprocessors): # --- 7. 최종 피처 병합 및 정렬 --- if not feature_list: print("오류: 생성된 피처가 없습니다. 전처리기를 확인하세요.") - return None + raise Exception("피처 엔지니어링 결과가 비어있습니다. (feature_list is empty)") final_features_df = pd.concat(feature_list, axis=1)