Package com.bytedesk.core.server_metrics
Class ServerMetricsRestController
java.lang.Object
com.bytedesk.core.base.BaseRestController<ServerMetricsRequest,ServerMetricsRestService>
com.bytedesk.core.server_metrics.ServerMetricsRestController
@RestController
@RequestMapping("/api/v1/server-metrics")
@Description("Server Metrics Management Controller - Server performance monitoring and metrics analysis APIs")
public class ServerMetricsRestController
extends BaseRestController<ServerMetricsRequest,ServerMetricsRestService>
REST controller for server metrics operations
Provides APIs for server metrics CRUD operations and historical data queries
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ServerMetricsRestService
private final ServerRestService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Integer>
cleanupOldMetrics
(Integer retentionDays) Clean up old metrics data (admin only)org.springframework.http.ResponseEntity<?>
create
(ServerMetricsRequest request) 通用的create实现 减少子类重复代码org.springframework.http.ResponseEntity<?>
delete
(ServerMetricsRequest request) 通用的delete实现 减少子类重复代码export
(ServerMetricsRequest request, jakarta.servlet.http.HttpServletResponse response) exportorg.springframework.http.ResponseEntity<List<ServerMetricsEntity>>
findHighUsageMetrics
(Double cpuThreshold, Double memoryThreshold, Double diskThreshold, ZonedDateTime startTime, ZonedDateTime endTime) Find metrics with high resource usageorg.springframework.http.ResponseEntity<ServerMetricsRestService.ServerMetricsAverage>
getAverageMetrics
(String serverUid, ZonedDateTime startTime, ZonedDateTime endTime) Get average metrics for a server in a time rangeorg.springframework.http.ResponseEntity<List<ServerMetricsEntity>>
getCurrentServerMetricsHistory
(ZonedDateTime startTime, ZonedDateTime endTime) Get metrics history for current serverorg.springframework.http.ResponseEntity<ServerMetricsEntity>
getLatestMetrics
(String serverUid) Get latest metrics for a serverorg.springframework.http.ResponseEntity<Long>
getMetricsCount
(String serverUid) Get metrics count for a serverorg.springframework.http.ResponseEntity<List<ServerMetricsEntity>>
getMetricsHistory
(String serverUid, ZonedDateTime startTime, ZonedDateTime endTime) Get metrics history for a serverorg.springframework.http.ResponseEntity<ServerMetricsRestService.ServerMetricsPeak>
getPeakMetrics
(String serverUid, ZonedDateTime startTime, ZonedDateTime endTime) Get peak metrics for a server in a time rangeorg.springframework.http.ResponseEntity<?>
queryByOrg
(ServerMetricsRequest request) 通用的queryByOrg实现 减少子类重复代码org.springframework.http.ResponseEntity<?>
queryByUid
(ServerMetricsRequest request) 通用的queryByUid实现 减少子类重复代码org.springframework.http.ResponseEntity<?>
queryByUser
(ServerMetricsRequest request) 通用的queryByUser实现 减少子类重复代码org.springframework.http.ResponseEntity<?>
update
(ServerMetricsRequest request) 通用的update实现 减少子类重复代码Methods inherited from class com.bytedesk.core.base.BaseRestController
deleteByOrgUid, exportTemplate, getService
-
Field Details
-
serverMetricsRestService
-
serverRestService
-
-
Constructor Details
-
ServerMetricsRestController
public ServerMetricsRestController()
-
-
Method Details
-
queryByOrg
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u7ec4\u7ec7\u67e5\u8be2", description="query server metrics by org") public org.springframework.http.ResponseEntity<?> queryByOrg(ServerMetricsRequest request) Description copied from class:BaseRestController
通用的queryByOrg实现 减少子类重复代码- Overrides:
queryByOrg
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService>
-
queryByUser
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u7528\u6237\u67e5\u8be2", description="query server metrics by user") public org.springframework.http.ResponseEntity<?> queryByUser(ServerMetricsRequest request) Description copied from class:BaseRestController
通用的queryByUser实现 减少子类重复代码- Overrides:
queryByUser
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService>
-
queryByUid
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u67e5\u8be2\u8be6\u60c5", description="query server metrics by uid") public org.springframework.http.ResponseEntity<?> queryByUid(ServerMetricsRequest request) Description copied from class:BaseRestController
通用的queryByUid实现 减少子类重复代码- Overrides:
queryByUid
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService>
-
create
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u65b0\u5efa", description="create server metrics") public org.springframework.http.ResponseEntity<?> create(ServerMetricsRequest request) Description copied from class:BaseRestController
通用的create实现 减少子类重复代码- Overrides:
create
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService>
-
update
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u66f4\u65b0", description="update server metrics") public org.springframework.http.ResponseEntity<?> update(ServerMetricsRequest request) Description copied from class:BaseRestController
通用的update实现 减少子类重复代码- Overrides:
update
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService>
-
delete
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u5220\u9664", description="delete server metrics") public org.springframework.http.ResponseEntity<?> delete(ServerMetricsRequest request) Description copied from class:BaseRestController
通用的delete实现 减少子类重复代码- Overrides:
delete
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService>
-
export
@ActionAnnotation(title="\u670d\u52a1\u5668\u6307\u6807", action="\u5bfc\u51fa", description="export server metrics") @GetMapping("/export") public Object export(ServerMetricsRequest request, jakarta.servlet.http.HttpServletResponse response) Description copied from class:BaseRestController
export- Overrides:
export
in classBaseRestController<ServerMetricsRequest,
ServerMetricsRestService> - Parameters:
request
- role- Returns:
- json
-
getMetricsHistory
@GetMapping("/history/{serverUid}") public org.springframework.http.ResponseEntity<List<ServerMetricsEntity>> getMetricsHistory(@PathVariable String serverUid, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime startTime, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime endTime) Get metrics history for a server- Parameters:
serverUid
- server UIDstartTime
- start time (ISO format: yyyy-MM-ddTHH:mm:ssZ)endTime
- end time (ISO format: yyyy-MM-ddTHH:mm:ssZ)- Returns:
- list of metrics
-
getLatestMetrics
@GetMapping("/latest/{serverUid}") public org.springframework.http.ResponseEntity<ServerMetricsEntity> getLatestMetrics(@PathVariable String serverUid) Get latest metrics for a server- Parameters:
serverUid
- server UID- Returns:
- latest metrics
-
getAverageMetrics
@GetMapping("/average/{serverUid}") public org.springframework.http.ResponseEntity<ServerMetricsRestService.ServerMetricsAverage> getAverageMetrics(@PathVariable String serverUid, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime startTime, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime endTime) Get average metrics for a server in a time range- Parameters:
serverUid
- server UIDstartTime
- start timeendTime
- end time- Returns:
- average metrics
-
getPeakMetrics
@GetMapping("/peak/{serverUid}") public org.springframework.http.ResponseEntity<ServerMetricsRestService.ServerMetricsPeak> getPeakMetrics(@PathVariable String serverUid, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime startTime, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime endTime) Get peak metrics for a server in a time range- Parameters:
serverUid
- server UIDstartTime
- start timeendTime
- end time- Returns:
- peak metrics
-
findHighUsageMetrics
@GetMapping("/high-usage") public org.springframework.http.ResponseEntity<List<ServerMetricsEntity>> findHighUsageMetrics(@RequestParam(defaultValue="80.0") Double cpuThreshold, @RequestParam(defaultValue="80.0") Double memoryThreshold, @RequestParam(defaultValue="85.0") Double diskThreshold, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime startTime, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime endTime) Find metrics with high resource usage- Parameters:
cpuThreshold
- CPU usage threshold (default: 80.0)memoryThreshold
- memory usage threshold (default: 80.0)diskThreshold
- disk usage threshold (default: 85.0)startTime
- start timeendTime
- end time- Returns:
- list of metrics with high usage
-
getMetricsCount
@GetMapping("/count/{serverUid}") public org.springframework.http.ResponseEntity<Long> getMetricsCount(@PathVariable String serverUid) Get metrics count for a server- Parameters:
serverUid
- server UID- Returns:
- metrics count
-
cleanupOldMetrics
@DeleteMapping("/cleanup") public org.springframework.http.ResponseEntity<Integer> cleanupOldMetrics(@RequestParam(defaultValue="30") Integer retentionDays) Clean up old metrics data (admin only)- Parameters:
retentionDays
- number of days to retain (default: 30)- Returns:
- number of deleted records
-
getCurrentServerMetricsHistory
@GetMapping("/current/history") public org.springframework.http.ResponseEntity<List<ServerMetricsEntity>> getCurrentServerMetricsHistory(@RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime startTime, @RequestParam @DateTimeFormat(iso=DATE_TIME) ZonedDateTime endTime) Get metrics history for current server- Parameters:
startTime
- start timeendTime
- end time- Returns:
- list of metrics for current server
-