-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpipeline.py
More file actions
43 lines (32 loc) · 1.18 KB
/
Copy pathpipeline.py
File metadata and controls
43 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import time
import re
import fast_log_parser
from cluster_templates import TemplateClusterer
from anomaly_detector import ParameterAnomalyDetector
from root_cause import RootCauseLocator
parser = fast_log_parser.FastParser()
clusterer = TemplateClusterer(similarity_threshold=0.7)
param_detector = ParameterAnomalyDetector(contamination=0.01)
locator = RootCauseLocator()
log_file_path = "HDFS_2k.log"
line_count = 0
start_time = time.time()
with open(log_file_path, "r") as file:
for line in file:
log = line.strip()
if not log: continue
res = parser.parse_line(log)
tid = res['template_id']
if res['is_new']:
mid, _ = clusterer.add_template(tid, res['clean_log'])
else:
mid = clusterer.cluster_map.get(tid, tid)
param_anom, _ = param_detector.process_log(mid, log)
blk_match = re.search(r'(blk_-?\d+)', log)
if blk_match:
locator.add_log(mid, blk_match.group(1), line_count)
line_count += 1
duration = time.time() - start_time
print(f"Processed {line_count} lines.")
print(f"Time: {duration:.4f}s")
print("Full pipeline integrated.")