Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-*"):
"""
Expand Down Expand Up @@ -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:
Expand All @@ -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에서 함수 가져옴)
Expand Down Expand Up @@ -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에 대해 개별 클러스터링 수행 중...")
Expand Down
2 changes: 1 addition & 1 deletion src/es_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
raise e
2 changes: 1 addition & 1 deletion src/feature_engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading