mirror of
https://github.com/napnap75/multiarch-docker-images.git
synced 2026-09-25 20:31:52 +02:00
feat: Refactor log-alert application into modular structure
- Introduced alerters package with base Alerter class and implementations for LogAlerter and GotifyAlerter. - Created fetchers package with abstract LogFetcher class and implementations for FileLogFetcher, LokiLogFetcher, and ParseableLogFetcher. - Added filters package with base Filter class and implementations for RegexpFilter and GeolocationFilter. - Implemented rules package with base AlertRule class and SimpleAlertRule for alerting logic. - Enhanced configuration handling with utilities for loading and validating JSON configuration. - Updated logging setup for better logging management. - Modified main application logic to utilize the new modular structure, improving maintainability and readability. - Updated config.json and config.schema.json to reflect changes in alerting and fetching configurations. - Added python-dateutil to requirements for date parsing functionality.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Abstract base class for log fetchers."""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Any, List
|
||||
|
||||
|
||||
class LogFetcher(ABC):
|
||||
"""Abstract base class for log fetchers."""
|
||||
|
||||
"""Fetch logs."""
|
||||
@abstractmethod
|
||||
def fetch_logs(self, filters: Dict[str, Any]) -> List[Dict[str, Any]]:
|
||||
"""Fetch logs within the specified time range.
|
||||
|
||||
Args:
|
||||
filters: Dictionary of filters to apply
|
||||
|
||||
Returns:
|
||||
List of log entries
|
||||
"""
|
||||
pass
|
||||
|
||||
""" Fetch logs with time range."""
|
||||
@abstractmethod
|
||||
def fetch_logs_time_range(self, filters: Dict[str, Any], start_time: int, end_time: int) -> List[Dict[str, Any]]:
|
||||
"""Fetch logs within the specified time range.
|
||||
|
||||
Args:
|
||||
filters: Dictionary of filters to apply
|
||||
start_time: Start time in seconds since epoch
|
||||
end_time: End time in seconds since epoch
|
||||
|
||||
Returns:
|
||||
List of log entries
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user