|
7 | 7 |
|
8 | 8 | import logging |
9 | 9 | import os |
10 | | -from collections import Counter |
11 | 10 | from datetime import datetime, timedelta |
12 | 11 | from typing import Any, Dict, List |
13 | 12 |
|
|
16 | 15 |
|
17 | 16 | from ..config import create_error_response, safe_int_conversion |
18 | 17 | from .dynamodb_tool import fetch_document_record |
19 | | -from .models import LogEvent |
20 | 18 | from .xray_tool import extract_lambda_request_ids |
21 | 19 |
|
22 | 20 | logger = logging.getLogger(__name__) |
@@ -523,44 +521,6 @@ def _build_response( |
523 | 521 | return response |
524 | 522 |
|
525 | 523 |
|
526 | | -# ============================================================================= |
527 | | -# PUBLIC UTILITY FUNCTIONS |
528 | | -# ============================================================================= |
529 | | - |
530 | | - |
531 | | -def extract_error_keywords(log_events: List[LogEvent]) -> Dict[str, int]: |
532 | | - """ |
533 | | - Extract and count error keywords from log events. |
534 | | -
|
535 | | - Args: |
536 | | - log_events: List of LogEvent objects |
537 | | -
|
538 | | - Returns: |
539 | | - Dict mapping error keywords to their occurrence counts |
540 | | - """ |
541 | | - error_keywords = [ |
542 | | - "error", |
543 | | - "exception", |
544 | | - "failed", |
545 | | - "failure", |
546 | | - "timeout", |
547 | | - "fatal", |
548 | | - "critical", |
549 | | - "denied", |
550 | | - "refused", |
551 | | - ] |
552 | | - |
553 | | - keyword_counts = Counter() |
554 | | - |
555 | | - for event in log_events: |
556 | | - message_lower = event.message.lower() |
557 | | - for keyword in error_keywords: |
558 | | - if keyword in message_lower: |
559 | | - keyword_counts[keyword] += 1 |
560 | | - |
561 | | - return dict(keyword_counts.most_common(10)) |
562 | | - |
563 | | - |
564 | 524 | # ============================================================================= |
565 | 525 | # PRIVATE HELPER FUNCTIONS |
566 | 526 | # ============================================================================= |
|
0 commit comments