-
Notifications
You must be signed in to change notification settings - Fork 715
feat: Alerts History api and the front end! #8894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive Alert History feature that allows users to view and analyze alert execution history through a new backend API endpoint and dedicated frontend interface. The implementation queries the _meta organization's triggers stream to display historical alert execution data including status, timing, errors, and performance metrics.
Key Changes:
- New backend endpoint
/api/{org_id}/alerts/historywith pagination and filtering support - Full-featured Vue component with advanced search, time-based filtering, and detailed execution logs
- Navigation integration from the alerts list page to the history view
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
web/src/services/alerts.ts |
Added getHistory service method and trailing comma formatting fixes |
web/src/composables/shared/router.ts |
Registered new alertHistory route |
web/src/components/alerts/AlertList.vue |
Added "Alert History" navigation button and code formatting improvements |
web/src/components/alerts/AlertHistory.vue |
New component implementing the full alert history UI with table, filters, and detail views |
src/handler/http/router/openapi.rs |
Registered history endpoint in OpenAPI spec |
src/handler/http/router/mod.rs |
Added history route to service configuration |
src/handler/http/request/alerts/mod.rs |
Added history module export |
src/handler/http/request/alerts/history.rs |
New handler implementing alert history query logic and response formatting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| const response = await alertsService.getHistory(org, query); | ||
|
|
||
| console.log("Alert history response:", response); |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple console.log statements should be removed from production code. These debug logs expose internal application state and API details that should not be visible in production. Consider using a proper logging framework with configurable log levels, or remove these statements entirely.
| startTime: fifteenMinutesAgo * 1000, // Convert to microseconds | ||
| endTime: now * 1000, // Convert to microseconds |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect time conversion: The comment states 'Convert to microseconds' but the code multiplies by 1000, which converts milliseconds to microseconds. However, Date.now() returns milliseconds, so multiplying by 1000 only converts to microseconds (×10^6 from seconds), not the full conversion from milliseconds. To properly convert to microseconds, multiply by 1000 again: now * 1000 * 1000 or now * 1_000_000.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR implements a comprehensive Alert History feature that provides visibility into alert execution history through both backend and frontend components.
Key Changes:
- New Rust endpoint
/api/{org_id}/alerts/historyqueries the_metaorganization's triggers stream for alert execution data - Full-featured Vue component with filtering, search, pagination, and detailed execution views
- Proper integration with existing alert management UI via navigation button in AlertList
Critical Issues Found:
- SQL injection vulnerabilities in
history.rslines 170 and 173-178 where alert names are directly interpolated into LIKE clauses without escaping - Unused import
TRIGGERS_KEYin history.rs
Positive Aspects:
- Well-structured code with proper error handling in both backend and frontend
- Comprehensive UI with date/time filtering, status visualization, and detailed modal views
- Proper pagination and time range validation
- Good integration with existing codebase patterns
Confidence Score: 2/5
- This PR has critical SQL injection vulnerabilities that must be fixed before merging
- Score reflects two critical SQL injection vulnerabilities in the backend handler where user-controlled and database-sourced alert names are directly interpolated into SQL LIKE clauses without proper escaping. These vulnerabilities could allow SQL injection attacks. The frontend implementation is solid, but the security issues in the backend are blocking.
- Pay close attention to
src/handler/http/request/alerts/history.rs- contains SQL injection vulnerabilities that must be resolved
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/handler/http/request/alerts/history.rs | 2/5 | New alert history endpoint with SQL injection vulnerabilities in LIKE clause construction (lines 170, 173-178) and unused import |
| web/src/components/alerts/AlertHistory.vue | 4/5 | New Vue component for alert history with comprehensive functionality, proper error handling, and time conversion logic - minor style improvements possible |
| web/src/services/alerts.ts | 5/5 | Added getHistory API method with proper query parameter handling and formatting cleanup - no issues found |
Sequence Diagram
sequenceDiagram
participant User as User Browser
participant AlertList as AlertList.vue
participant AlertHistory as AlertHistory.vue
participant AlertService as alerts.ts
participant Router as Vue Router
participant Backend as Rust Handler
participant AlertDB as Alert DB
participant MetaOrg as _meta Org Search
User->>AlertList: Click "Alert History" button
AlertList->>Router: Navigate to /alerts/history
Router->>AlertHistory: Load AlertHistory.vue
activate AlertHistory
AlertHistory->>AlertService: fetchAlertsList()
AlertService->>Backend: GET /api/{org}/alerts
Backend->>AlertDB: list_alerts(org_id)
AlertDB-->>Backend: List of alert names
Backend-->>AlertService: Alert list response
AlertService-->>AlertHistory: Alert names for dropdown
AlertHistory->>AlertService: getHistory(org, query params)
AlertService->>Backend: GET /api/{org}/alerts/history?params
activate Backend
Backend->>AlertDB: get_organization_alert_names(org_id)
AlertDB-->>Backend: Alert names
Note over Backend: Validate alert_name filter<br/>if provided
Backend->>Backend: Build SQL query with<br/>LIKE clauses for alert names
Backend->>MetaOrg: SearchService::search()<br/>Query _meta org triggers stream
MetaOrg-->>Backend: Search results with<br/>alert execution history
Backend->>Backend: Parse hits into<br/>AlertHistoryEntry objects
Backend-->>AlertService: AlertHistoryResponse<br/>(total, from, size, hits)
deactivate Backend
AlertService-->>AlertHistory: History data
AlertHistory->>AlertHistory: Format dates, durations,<br/>status colors
AlertHistory->>User: Display table with<br/>execution history
deactivate AlertHistory
User->>AlertHistory: Click "View Details"
AlertHistory->>User: Show modal with<br/>detailed execution info
8 files reviewed, 3 comments
| }, | ||
| utils::time::now_micros, | ||
| }; | ||
| use infra::scheduler::TRIGGERS_KEY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: TRIGGERS_KEY is imported but never used - remove unused import
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/handler/http/request/alerts/history.rs
Line: 27:27
Comment:
**style:** `TRIGGERS_KEY` is imported but never used - remove unused import
How can I resolve this? If you propose a fix, please make it concise.74e37b0 to
b27830c
Compare
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 339 | 0 | 19 | 7 | 93% | 7m 5s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add history key in en.json file there we have alerts object it will pick up from that file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to this we can add all other keys that we use in columns header into the same file it will be picked up
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 344 | 0 | 19 | 2 | 94% | 4m 38s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 342 | 0 | 19 | 4 | 94% | 4m 39s |
dd3e997 to
50e60c7
Compare
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 341 | 0 | 19 | 5 | 93% | 4m 40s |
50e60c7 to
6c4823b
Compare
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 342 | 0 | 19 | 4 | 94% | 4m 38s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 341 | 0 | 19 | 5 | 93% | 7m 5s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 340 | 0 | 19 | 6 | 93% | 4m 40s |
9320c94 to
bf23b82
Compare
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 345 | 0 | 19 | 1 | 95% | 4m 39s |
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 365 | 343 | 0 | 19 | 3 | 94% | 4m 39s |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
0b9a1f1 to
9159948
Compare
|
| Status | Total | Passed | Failed | Skipped | Flaky | Pass Rate | Duration |
|---|---|---|---|---|---|---|---|
| All tests passed | 366 | 346 | 0 | 19 | 1 | 95% | 4m 41s |
PR Type
Enhancement
Description
This PR implements a comprehensive Alert History view for OpenObserve, providing users with detailed visibility into alert execution history. The feature includes a dedicated history page accessible from the alerts list, complete with advanced filtering, search capabilities, and detailed execution logs.
Features Implemented
1. New Alert History Backend Endpoint (
/api/{org_id}/alerts/history)/src/handler/http/request/alerts/history.rs_metaorganization's triggers stream for alert execution dataalert_name: Filter by specific alertstart_time&end_time: Time range in microsecondsfrom&size: Pagination support (max 1000 records)2. Alert History Vue Component (
/web/src/components/alerts/AlertHistory.vue)3. Advanced Search Functionality
4. DateTime Picker Integration
5. Alert Details Modal
6. Navigation Integration
/alerts/history