How opsre/watchalert works
Main components
• Alert Engine Modules: These are primarily under the “alert” directory and include submodules for alert consumption, evaluation (eval), mute, probing, process, and storage. Each subcomponent deals with different parts of alert handling & processing.
• API Layer: The “api” directory contains many files for endpoints (e.g., dashboard, event, user, rule management, notifications) that expose the system’s functionalities to users and external clients.
• Internal Core & Services: Under “internal” you have caches, middleware, models, repositories, routers, and services. These components handle business logic such as auditing, authentication, tenant management, and data persistence.
• Providers & External Integration: The “pkg/provider” and “pkg/community” directories integrate with third-party systems (e.g., AWS Cloudwatch, Kubernetes, various monitoring tools). They encapsulate connectivity to data sources.
• Notification & Template Senders: In “pkg/sender” and “pkg/templates”, there are integrations for sending alerts as notifications (via email, Dingding, WeChat, Feishu, custom webhooks, or phone calls).
• Initialization & Configuration: “initialization” and “config” provide app startup routines, routing configuration, and overall configuration management.
• Deployment & Infrastructure: The “deploy” directory (including docker-compose and Kubernetes YAMLs, plus SQL scripts) gives insights into how the system is containerized and managed in production.
Relationships and interactions between components
• Data Sources & Providers: Start by showing external monitoring tools, cloud services, and network probes that feed data. These will connect into the “pkg/provider” and “pkg/community” modules.
• Alert Processing Pipeline: Data flows into the Alert Engine (components under “alert”) where alerts are consumed, evaluated (with AI analysis), processed (including muting and probing), and finally stored.
• API Exposure: The API layer (“api” and “internal/routers/v1”) exposes functionalities for configuration, alert management, dashboards, user management, and more. It interacts with the underlying core (internal models, repositories, and services).
• Notification Dispatch: Once an alert is processed, notifications are sent out through the “pkg/sender” modules based on user configurations and preferences.
• Configuration and Middleware: Global settings/control provided via “config” and “internal/middleware” manage cross-cutting concerns such as logging, authentication, auditing, CORS, and permissions.
• Deployment/Containerization: Represent how the components are packaged and orchestrated using Docker (Dockerfile, docker-compose) and Kubernetes (in deploy/kubernetes).
Architectural patterns/design principles
• Layered Architecture: Separation between data ingestion, business logic, and API presentation layers.
• Modular Design: Each core function (alert evaluation, processing, notification dispatch) is contained in its own module.
• Integration of Third-Party Services: The project abstracts integrations (metrics, logs, traces, network probes) into dedicated provider packages.
• Configurability & Extensibility: Directories like “config”, “deploy”, and “pkg/templates” indicate a design that allows easy extension and configuration for different environments.