shuideyimei opened a new pull request, #11980:
URL: https://github.com/apache/inlong/pull/11980
[INLONG-11923][Manager] Add comprehensive audit alert rule management API
Fixes #11923
### Motivation
Currently, Apache InLong lacks a comprehensive audit alert rule management
system to monitor data quality, detect anomalies, and provide real-time
alerting capabilities. Users need the ability to create, manage, and monitor
audit alert rules to ensure data pipeline reliability and quality.
This enhancement adds a complete audit alert rule management API that allows
users to:
- Configure alert rules for data count, delay, and quality metrics
- Set up notification channels (EMAIL, SMS, etc.)
- Manage alert rule lifecycle (create, update, delete, enable/disable)
- Query and filter alert rules by group and stream
### Modifications
**1. Data Model Layer**
- Added
[AuditAlertRule](file://e:\inlong\inlong-manager\manager-pojo\src\main\java\org\apache\inlong\manager\pojo\audit\AuditAlertRule.java#L25-L63)
POJO class in `manager-pojo` module with comprehensive validation annotations
- Added
[AuditAlertRuleEntity](file://e:\inlong\inlong-manager\manager-dao\src\main\java\org\apache\inlong\manager\dao\entity\AuditAlertRuleEntity.java#L23-L39)
database entity in `manager-dao` module for MyBatis mapping
- Added
[AuditAlertRuleEntityMapper](file://e:\inlong\inlong-manager\manager-dao\src\main\java\org\apache\inlong\manager\dao\mapper\AuditAlertRuleEntityMapper.java#L24-L32)
interface with full CRUD operations
- Added MyBatis XML mapping file
[AuditAlertRuleEntityMapper.xml](file://e:\inlong\inlong-manager\manager-dao\src\main\resources\mappers\AuditAlertRuleEntityMapper.xml)
with optimized SQL queries
**2. Service Layer**
- Extended
[AuditService](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\AuditService.java#L31-L103)
interface with audit alert rule management methods
- Implemented audit alert rule management in
[AuditServiceImpl](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\impl\AuditServiceImpl.java#L78-L446)
class:
-
[createAlertRule()](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\AuditService.java#L87-L87)
- Create new alert rules with validation
-
[getAlertRule()](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\AuditService.java#L92-L92)
- Retrieve alert rule by ID
-
[updateAlertRule()](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\AuditService.java#L97-L97)
- Update existing alert rules
-
[deleteAlertRule()](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\AuditService.java#L102-L102)
- Delete alert rules
-
[listAlertRules()](file://e:\inlong\inlong-manager\manager-service\src\main\java\org\apache\inlong\manager\service\core\AuditService.java#L82-L82)
- Query alert rules with filtering support
**3. Web Layer**
- Added REST API endpoints in
[AuditController](file://e:\inlong\inlong-manager\manager-web\src\main\java\org\apache\inlong\manager\web\controller\AuditController.java#L51-L137):
- `POST /api/audit/alert/rule` - Create alert rule
- `GET /api/audit/alert/rule/{id}` - Get alert rule by ID
- `PUT /api/audit/alert/rule` - Update alert rule
- `DELETE /api/audit/alert/rule/{id}` - Delete alert rule
- `GET /api/audit/alert/rule/list` - List alert rules with filtering
- `GET /api/audit/alert/rule/enabled` - Get all enabled alert rules
**4. Database Schema**
- Database table `audit_alert_rule` with optimized indexes
- Support for MySQL with proper charset and collation
**5. Testing**
- Comprehensive unit tests in
[AuditAlertRuleTest](file://e:\inlong\inlong-manager\manager-service\src\test\java\org\apache\inlong\manager\service\core\AuditAlertRuleTest.java#L34-L152)
class
- API integration test scripts for manual validation
- Database initialization SQL scripts
**6. Configuration**
- MyBatis configuration for audit alert rule mapping
- Spring Boot auto-configuration support
### Verifying this change
- [x] This change added tests and can be verified as follows:
**Unit Tests:**
- Added
[AuditAlertRuleTest](file://e:\inlong\inlong-manager\manager-service\src\test\java\org\apache\inlong\manager\service\core\AuditAlertRuleTest.java#L34-L152)
class with comprehensive test coverage:
- Test alert rule creation with validation
- Test alert rule retrieval and updates
- Test alert rule deletion and lifecycle management
- Test query operations with filtering
- Test error handling and edge cases
**Integration Tests:**
- Added API test scripts
([test-audit-alert-api.sh](file://e:\inlong\inlong-manager\test-audit-alert-api.sh)
and
[test-audit-alert-api.ps1](file://e:\inlong\inlong-manager\test-audit-alert-api.ps1))
- Added database initialization script
([init-audit-alert-test-data.sql](file://e:\inlong\inlong-manager\init-audit-alert-test-data.sql))
- Manual testing workflow documented
**Test Coverage:**
- Service layer: Full CRUD operations testing
- Controller layer: HTTP endpoint testing with various scenarios
- Data layer: MyBatis mapping and SQL query validation
- Error handling: Input validation and exception scenarios
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]