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:
2026-08-30 23:22:38 +02:00
parent b7f1b97434
commit a5337c3d29
23 changed files with 627 additions and 261 deletions
+6 -6
View File
@@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Log Alert configuration schema",
"type": "object",
"required": ["log-fetchers", "alert-managers", "alerting-rules"],
"required": ["log-fetchers", "alerters", "alerting-rules"],
"properties": {
"log-fetchers": {
"type": "object",
@@ -10,18 +10,18 @@
"type": "object",
"required": ["type", "config"],
"properties": {
"type": { "type": "string", "enum": ["loki"] },
"type": { "type": "string", "enum": ["file", "loki", "parseable"] },
"config": { "type": "object" }
}
}
},
"alert-managers": {
"alerters": {
"type": "object",
"additionalProperties": {
"type": "object",
"required": ["type", "config"],
"properties": {
"type": { "type": "string", "enum": ["gotify"] },
"type": { "type": "string", "enum": ["log", "gotify"] },
"config": { "type": "object" }
}
}
@@ -30,7 +30,7 @@
"type": "object",
"additionalProperties": {
"type": "object",
"required": ["check-interval", "log-fetcher", "filters", "alert-manager"],
"required": ["check-interval", "log-fetcher", "filters", "alerter"],
"properties": {
"check-interval": { "type": "number", "minimum": 0 },
"log-fetcher": {
@@ -53,7 +53,7 @@
}
}
},
"alert-manager": {
"alerter": {
"type": "object",
"required": ["name"],
"properties": {