12 Commits

Author SHA1 Message Date
e286fa9eaf feat(metrics): enhance metrics retention and improve data handling
- Introduced new constants for data retention periods, specifying retention for metrics, status codes, paths, and referers to improve data management.
- Updated the MetricsHistoryHandler to accept floating-point hours for more precise time queries, enhancing the flexibility of historical data retrieval.
- Enhanced the metrics dashboard layout with additional CSS styles for better visual presentation and user experience.
- Improved error handling in the response writing process to ensure robust logging of connection issues.
- Implemented a new function to check for connection closure errors, improving the reliability of the proxy handler.

These changes significantly enhance the metrics collection, retention, and user interface, providing a more robust framework for performance monitoring and data analysis.
2024-12-05 07:57:02 +08:00
26c945a3f9 feat(metrics): enhance metrics dashboard and data handling
- Improved the metrics dashboard layout with new styles for better visual presentation, including enhanced chart and control elements.
- Added functionality for auto-refreshing metrics and exporting data to CSV, improving user interaction and data accessibility.
- Implemented persistent statistics tracking in the collector, allowing for historical data retrieval and better performance monitoring.
- Enhanced database operations with optimizations for saving metrics and cleaning up old data, ensuring efficient data management.
- Introduced performance metrics tracking, providing insights into average response times and throughput.

These changes significantly enhance the usability and functionality of the metrics dashboard, providing a more robust framework for performance monitoring and data analysis.
2024-12-05 07:08:08 +08:00
2d658c35e6 fix(metrics): refine SQL query for recent metrics retrieval
- Updated the SQL query in GetRecentMetrics to adjust the time filtering logic, ensuring that only metrics within the specified hours are retrieved.
- This change enhances the accuracy of the metrics data by correctly bounding the time range, improving the reliability of performance monitoring.
2024-12-05 06:51:16 +08:00
c416c76790 feat(metrics): implement full metrics saving and enhance database schema
- Added functionality to save full metrics periodically and on application shutdown, improving data persistence.
- Introduced new database tables for performance metrics, status code history, popular paths, and referer history, enhancing data tracking capabilities.
- Updated the GetRecentMetrics function to utilize window functions for more accurate metrics retrieval and ensure non-negative values.
- Improved data handling by ensuring empty records are returned instead of null when no metrics are available.

These changes significantly enhance the metrics collection and storage process, providing a more robust framework for performance monitoring.
2024-12-05 06:47:39 +08:00
c35d95f2cc fix(metrics): enhance metrics dashboard layout and optimize database queries
- Increased the bottom margin of charts in the metrics dashboard for improved visual spacing.
- Added titles to the charts for better context and understanding of displayed data.
- Introduced composite indexes in the database to optimize aggregation queries and improve performance.
- Modified the SQL query in GetRecentMetrics to calculate incremental changes in metrics, enhancing data accuracy and usability.

These changes improve the user experience by providing clearer visualizations and more efficient data retrieval in the metrics dashboard.
2024-12-05 01:46:25 +08:00
660e60576d fix(metrics): enhance metrics chart rendering and data handling
- Updated the metrics chart rendering logic to reverse the data order for a more intuitive time progression from left to right.
- Introduced chart options to ensure the x-axis is not reversed, improving the clarity of time-based data visualization.
- Modified the updateChart function to accept additional options, allowing for more flexible chart configurations.
- Added a safeguard in GetRecentMetrics to return a default empty record instead of null when no metrics are available, enhancing data reliability.

These changes improve the user experience by providing clearer visualizations and ensuring consistent data handling in the metrics dashboard.
2024-12-05 01:13:11 +08:00
59358cbe8a fix(metrics): update SQL query to use localtime for accurate metrics retrieval
- Modified the SQL query in GetRecentMetrics to utilize the 'localtime' modifier for timestamp handling, ensuring that metrics are retrieved based on the local time zone.
- This change enhances the accuracy of the metrics data by aligning the time calculations with local time, improving the reliability of performance monitoring.
2024-12-05 01:06:55 +08:00
60b115438a fix(metrics): update AvgLatency type and improve SQL query for metrics retrieval
- Changed AvgLatency field type from int64 to float64 in HistoricalMetrics for better precision in latency measurements.
- Updated SQL query in GetRecentMetrics to ensure proper averaging of AvgLatency by casting to float, enhancing accuracy in metrics reporting.
- These changes improve the reliability of metrics data and ensure more accurate performance monitoring.
2024-12-04 11:57:08 +08:00
837820639f feat(metrics): implement database initialization and cleanup for metrics tracking
- Added initTables function to create necessary tables for metrics history, status statistics, and path statistics in the database.
- Implemented indexing on timestamp columns to enhance query performance.
- Introduced a cleanupRoutine function to periodically delete old metrics data based on retention policies, improving database management.
- Integrated logging for cleanup operations to monitor success and errors during the cleanup process.
2024-12-03 18:25:23 +08:00
1db0e6ae98 fix(metrics): update SQLite driver usage in MetricsDB initialization
- Changed the SQLite driver from "sqlite3" to "sqlite" in the NewMetricsDB function for improved compatibility with the new driver.
- This change aligns with the recent dependency update to modernc.org/sqlite, enhancing performance and stability.
2024-12-03 17:59:20 +08:00
54053f3a92 chore(dependencies): update SQLite driver and add indirect dependencies
- Replaced `github.com/mattn/go-sqlite3` with `modernc.org/sqlite` for improved compatibility and performance.
- Updated `go.mod` and `go.sum` to include several indirect dependencies for enhanced functionality and stability.
- Refactored import statements in `metrics.go` and `db.go` to reflect the new SQLite driver.
2024-12-03 17:57:31 +08:00
68c27b544b feat(metrics): enhance metrics functionality and configuration
- Added new dependency on github.com/mattn/go-sqlite3 for improved metrics storage.
- Updated main.go to initialize metrics collector with a new database path and configuration settings.
- Enhanced config.json to include additional metrics settings such as alert configurations and latency thresholds.
- Refactored internal metrics handling to support new metrics structures and improve data retrieval.
- Introduced a new metrics history endpoint for retrieving historical data, enhancing monitoring capabilities.
- Improved UI for metrics dashboard to include historical data visualization options.
2024-12-03 17:48:11 +08:00