Skip to content

Conversation

@yaga-simha
Copy link
Contributor

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)

  • Created new Rust handler at /src/handler/http/request/alerts/history.rs
  • Queries the _meta organization's triggers stream for alert execution data
  • Supports query parameters:
    • alert_name: Filter by specific alert
    • start_time & end_time: Time range in microseconds
    • from & size: Pagination support (max 1000 records)
  • Returns comprehensive execution details including status, timing, errors, and performance metrics

2. Alert History Vue Component (/web/src/components/alerts/AlertHistory.vue)

  • Full-featured table view with server-side pagination
  • Column display for: Timestamp, Alert Name, Status, Type, Silenced state, Duration, Retries, Errors, and Actions
  • Smart status indicators with color-coded chips
  • Responsive design with dark/light theme support

3. Advanced Search Functionality

  • Dropdown with type-ahead search: Users can select from existing alerts or type custom names
  • Manual search button: Reduces backend load by eliminating automatic API calls
  • Debounced search removed: Prevents excessive API requests while typing
  • Fetches alert list using the same pattern as AlertList.vue for consistency

4. DateTime Picker Integration

  • Properly integrated DateTime component (replaced incorrect DateTimePicker)
  • Supports both relative (15m, 1h, 1d, etc.) and absolute date selection
  • Default time range: Last 15 minutes
  • Time values correctly handled in microseconds for API compatibility

5. Alert Details Modal

  • Non-maximized modal dialog (700px width, 80vw max)
  • Organized sections with visual separators:
    • Basic Information (name, status)
    • Time Information (timestamp, duration)
    • Alert Configuration (type, silenced state)
    • Performance Metrics (evaluation time, query time, retries)
    • Error/Success details with syntax highlighting
  • Scrollable content with custom styled scrollbars
  • Professional UI with icons and proper typography hierarchy

6. Navigation Integration

  • Added "Alert History" button to AlertList.vue with history icon
  • Proper routing configuration at /alerts/history
  • Back navigation to alerts list
  • Organization-scoped data with automatic refresh on org change
Screenshot 2025-10-28 at 10 18 12 AM Screenshot 2025-10-28 at 10 18 42 AM Screenshot 2025-10-28 at 10 19 08 AM

@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

Copy link
Contributor

Copilot AI left a 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/history with 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);
Copy link

Copilot AI Oct 28, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +528 to +527
startTime: fifteenMinutesAgo * 1000, // Convert to microseconds
endTime: now * 1000, // Convert to microseconds
Copy link

Copilot AI Oct 28, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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/history queries the _meta organization'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.rs lines 170 and 173-178 where alert names are directly interpolated into LIKE clauses without escaping
  • Unused import TRIGGERS_KEY in 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
Loading

8 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

},
utils::time::now_micros,
};
use infra::scheduler::TRIGGERS_KEY;
Copy link
Contributor

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.

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: b27830c

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 339 0 19 7 93% 7m 5s

View Detailed Results

Copy link
Contributor

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

Copy link
Contributor

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

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: b27830c

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 344 0 19 2 94% 4m 38s

View Detailed Results

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: b27830c

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 342 0 19 4 94% 4m 39s

View Detailed Results

@yaga-simha yaga-simha force-pushed the feat/alerts-history branch 2 times, most recently from dd3e997 to 50e60c7 Compare October 28, 2025 06:11
@nikhilsaikethe nikhilsaikethe self-requested a review October 28, 2025 06:17
@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 50e60c7

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 341 0 19 5 93% 4m 40s

View Detailed Results

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 6c4823b

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 342 0 19 4 94% 4m 38s

View Detailed Results

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 3462d60

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 341 0 19 5 93% 7m 5s

View Detailed Results

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 9320c94

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 340 0 19 6 93% 4m 40s

View Detailed Results

@oasisk oasisk force-pushed the feat/alerts-history branch from 9320c94 to bf23b82 Compare October 28, 2025 09:51
@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 0b9a1f1

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 345 0 19 1 95% 4m 39s

View Detailed Results

@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 0b9a1f1

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 365 343 0 19 3 94% 4m 39s

View Detailed Results

@oasisk oasisk force-pushed the feat/alerts-history branch from 0b9a1f1 to 9159948 Compare October 28, 2025 11:14
@testdino-playwright-reporter
Copy link

⚠️ Test Run Unstable


Author: yaga-simha | Branch: feat/alerts-history | Commit: 9159948

Testdino Test Results

Status Total Passed Failed Skipped Flaky Pass Rate Duration
All tests passed 366 346 0 19 1 95% 4m 41s

View Detailed Results

@yaga-simha yaga-simha merged commit b004441 into main Oct 28, 2025
34 of 36 checks passed
@yaga-simha yaga-simha deleted the feat/alerts-history branch October 28, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants