Class MetricsController
java.lang.Object
com.nmontytskyi.monitoring.server.controller.MetricsController
@Validated
@RestController
@RequestMapping("/api/metrics")
public class MetricsController
extends Object
REST controller exposing the metric ingestion API for monitored microservices.
Accepts metric snapshots pushed by the
MetricsBuffer of each registered
service. Supports both single-record and batch endpoints to minimise HTTP overhead.
Every accepted snapshot is forwarded to
MetricsPersistenceService for
persistence, anomaly detection, and alert evaluation.
- Author:
- Nazar Montytskyi
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<AggregateMetricsResponse> getAggregate(Long serviceId, LocalDateTime from, LocalDateTime to) org.springframework.http.ResponseEntity<MetricRecordResponse> org.springframework.http.ResponseEntity<List<MetricRecordResponse>> pushBatch(@Valid List<@Valid MetricSnapshotRequest> batch) org.springframework.http.ResponseEntity<MetricRecordResponse> pushSnapshot(@Valid MetricSnapshotRequest request)
-
Constructor Details
-
MetricsController
public MetricsController()
-
-
Method Details
-
pushSnapshot
@PostMapping("/endpoint") public org.springframework.http.ResponseEntity<MetricRecordResponse> pushSnapshot(@Valid @RequestBody @Valid MetricSnapshotRequest request) -
pushBatch
@PostMapping("/batch") public org.springframework.http.ResponseEntity<List<MetricRecordResponse>> pushBatch(@Valid @RequestBody @Valid List<@Valid MetricSnapshotRequest> batch) -
getLatest
@GetMapping("/{serviceId}/latest") public org.springframework.http.ResponseEntity<MetricRecordResponse> getLatest(@PathVariable Long serviceId) -
getAggregate
@GetMapping("/{serviceId}/aggregate") public org.springframework.http.ResponseEntity<AggregateMetricsResponse> getAggregate(@PathVariable Long serviceId, @RequestParam @DateTimeFormat(iso=DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso=DATE_TIME) LocalDateTime to)
-