Skip to content

Conversation

@zqr10159
Copy link
Member

@zqr10159 zqr10159 commented Dec 12, 2025

This pull request introduces a new analysis module to the project, focused on time series forecasting and preprocessing. It adds a Maven module with its own dependencies, implements core algorithms for time series prediction (including a robust NLinear model and a lightweight Prophet-inspired model), and provides supporting infrastructure for data preprocessing and service abstraction.

Key changes include:

Module Setup and Dependencies

  • Added a new Maven module hertzbeat-analysis with its own pom.xml, specifying dependencies on core Hertzbeat modules, Spring Boot, and Apache Commons Math. Java 17 is set as the source/target version.

Core Algorithms for Time Series Forecasting

  • Implemented NLinearModel, an industrial-grade robust time series forecasting model using ridge regression (L2 regularization) for stability and overfitting prevention. Includes logic for flat line detection and fallback strategies.
  • Added TinyProphet, a lightweight time series forecasting model inspired by Prophet, using OLS regression with Fourier features for seasonality and trend detection.
  • Created PredictionResult as a data class to encapsulate forecast values and confidence intervals.

Data Preprocessing

  • Added TimeSeriesPreprocessor for resampling and interpolating time series data, handling missing values and aligning data to fixed time steps for model input.

Service Abstraction and Spring Integration

  • Defined AnalysisService interface for model training and forecasting, establishing a contract for future service implementations.
  • Added AnalysisModule as a Spring configuration class to enable component scanning for the new analysis package.
e5787bcc-b7ef-4333-9b84-21ac467e5351 cac01b3c-ca0e-4dc8-9b5c-bca81c37c85a image

zqr10159 and others added 10 commits December 8, 2025 22:23
- Created analysis module with Spring configuration
- Implemented AnalysisService interface for forecasting
- Added AnalysisServiceImpl with TinyProphet model integration
- Built TimeSeriesPreprocessor for data resampling and interpolation
- Developed TinyProphet algorithm using Fourier series and OLS regression
- Configured Maven module and dependencies including commons-math3
- Registered analysis module in parent pom.xml
- Added preprocessing and forecasting pipeline for historical metrics
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 pull request adds comprehensive time series forecasting functionality to HertzBeat, introducing a new analysis module with machine learning capabilities for predicting future metric values based on historical data. The implementation includes both backend forecasting algorithms and frontend visualization of predictions with confidence intervals.

Key Changes:

  • Added new hertzbeat-analysis Maven module with NLinear forecasting model using ridge regression and time series preprocessing capabilities
  • Implemented REST API endpoint /api/analysis/predict for time series prediction with automatic training window calculation
  • Enhanced frontend chart component to automatically load and visualize forecast data with confidence intervals after historical data loads

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
web-app/src/assets/i18n/zh-CN.json Added Chinese translations for forecast, confidence lower, and confidence upper labels
web-app/src/assets/i18n/en-US.json Added English translations for forecast visualization labels
web-app/src/app/service/monitor.service.ts Added new service method to call prediction API with history parameter
web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.ts Implemented auto-loading of prediction data and chart visualization with stacked confidence bands
script/sureness.yml (and docker-compose variants) Added security rules for /api/analysis/** endpoints accessible by admin and user roles
pom.xml Added hertzbeat-analysis module and commons-math3 dependency for statistical computations
hertzbeat-startup/src/main/resources/sureness.yml Added analysis API security configuration
hertzbeat-manager/src/test/resources/sureness.yml Added analysis API security configuration for tests
hertzbeat-manager/src/main/java/org/apache/hertzbeat/manager/controller/AnalysisController.java New controller implementing prediction endpoint with dynamic training window calculation and metric validation
hertzbeat-manager/pom.xml Added dependency on hertzbeat-analysis module
hertzbeat-e2e/hertzbeat-log-e2e/src/test/resources/sureness.yml Added analysis API security configuration for e2e tests
hertzbeat-collector/hertzbeat-collector-basic/pom.xml Formatting fix (newline at end of file)
hertzbeat-analysis/src/main/java/org/apache/hertzbeat/analysis/service/impl/AnalysisServiceImpl.java Service implementation orchestrating preprocessing, model training, and forecasting
hertzbeat-analysis/src/main/java/org/apache/hertzbeat/analysis/service/AnalysisService.java Service interface defining forecast contract
hertzbeat-analysis/src/main/java/org/apache/hertzbeat/analysis/algorithm/TimeSeriesPreprocessor.java Implements data resampling, interpolation, and gap filling for model input
hertzbeat-analysis/src/main/java/org/apache/hertzbeat/analysis/algorithm/PredictionResult.java Data class encapsulating forecast values with confidence bounds and timestamp
hertzbeat-analysis/src/main/java/org/apache/hertzbeat/analysis/algorithm/NLinearModel.java Core forecasting algorithm using ridge regression with flat-line detection and fallback strategies
hertzbeat-analysis/src/main/java/org/apache/hertzbeat/analysis/AnalysisModule.java Spring configuration enabling component scanning for analysis package
hertzbeat-analysis/pom.xml Maven configuration for new analysis module with dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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