diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java index cf5940cb3e..f5d6009cab 100644 --- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java +++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/monitoring/pipeline/ExtensionsLogProvider.java @@ -94,6 +94,14 @@ public SpMetricsEntry getMetricInfosForResource(String resourceId) { } } + public Map getMetricsInfoForResources(List resourceIds) { + return allMetricsInfos + .entrySet() + .stream() + .filter(entry -> resourceIds.contains(entry.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + public Map getMetricInfosForPipeline(String pipelineId) { var pipeline = PipelineManager.getPipeline(pipelineId); diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java index b3d91cda69..8260c4c9c6 100644 --- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java +++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/AdapterMonitoringResource.java @@ -20,6 +20,7 @@ package org.apache.streampipes.rest.impl; import org.apache.streampipes.manager.monitoring.pipeline.ExtensionsLogProvider; +import org.apache.streampipes.manager.monitoring.pipeline.ExtensionsServiceLogExecutor; import org.apache.streampipes.model.monitoring.SpLogEntry; import org.apache.streampipes.model.monitoring.SpMetricsEntry; @@ -28,9 +29,11 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/api/v2/adapter-monitoring") @@ -45,4 +48,12 @@ public ResponseEntity> getLogInfoForAdapter(@PathVariable("elem public ResponseEntity getMetricsInfoForAdapter(@PathVariable("elementId") String elementId) { return ok(ExtensionsLogProvider.INSTANCE.getMetricInfosForResource(elementId)); } + + @GetMapping(path = "metrics", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> getMetricsInfos( + @RequestParam(value = "filter") List elementIds + ) { + new ExtensionsServiceLogExecutor().triggerUpdate(); + return ok(ExtensionsLogProvider.INSTANCE.getMetricsInfoForResources(elementIds)); + } } diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/adapter-monitoring.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/adapter-monitoring.service.ts index 0ce1098f74..a208e6822c 100644 --- a/ui/projects/streampipes/platform-services/src/lib/apis/adapter-monitoring.service.ts +++ b/ui/projects/streampipes/platform-services/src/lib/apis/adapter-monitoring.service.ts @@ -47,6 +47,16 @@ export class AdapterMonitoringService extends AbstractMonitoringService { .pipe(map(response => response as SpMetricsEntry)); } + getMetricsInfoForAdapters( + elementIds: string[], + ): Observable> { + return this.http + .get(`${this.monitoringBasePath}/metrics`, { + params: { filter: elementIds.toString() }, + }) + .pipe(map(response => response as Record)); + } + protected get monitoringBasePath(): string { return `${this.platformServicesCommons.apiBasePath}/adapter-monitoring`; } diff --git a/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts b/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts index 7d880838e0..fdf0c5986f 100644 --- a/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts +++ b/ui/src/app/connect/components/existing-adapters/existing-adapters.component.ts @@ -185,22 +185,12 @@ export class ExistingAdaptersComponent implements OnInit, OnDestroy { } getMonitoringInfos(adapters: AdapterDescription[]) { - const observables = adapters - .map(adapter => adapter.elementId) - .map(elementId => - this.adapterMonitoringService.getMetricsInfoForAdapter( - elementId, - ), - ); + const filteredElementIds = adapters.map(adapter => adapter.elementId); this.adapterMonitoringService - .triggerMonitoringUpdate() - .subscribe(() => { - zip(...observables).subscribe(metrics => { - adapters.forEach((adapter, index) => { - this.adapterMetrics[adapter.elementId] = metrics[index]; - }); - }); + .getMetricsInfoForAdapters(filteredElementIds) + .subscribe(metrics => { + this.adapterMetrics = metrics; }); }