diff options
Diffstat (limited to 'metrics-proxy')
2 files changed, 15 insertions, 3 deletions
diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandler.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandler.java index e8da690ea9b..aa7ac3356cb 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandler.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandler.java @@ -6,6 +6,7 @@ import ai.vespa.metricsproxy.core.MetricsManager; import ai.vespa.metricsproxy.http.TextResponse; import ai.vespa.metricsproxy.http.ValuesFetcher; import ai.vespa.metricsproxy.metric.model.MetricsPacket; +import ai.vespa.metricsproxy.node.NodeMetricGatherer; import ai.vespa.metricsproxy.service.VespaServices; import com.yahoo.component.annotation.Inject; import com.yahoo.container.handler.metrics.HttpHandlerBase; @@ -13,6 +14,7 @@ import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.restapi.Path; import java.net.URI; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.concurrent.Executor; @@ -31,14 +33,17 @@ public class PrometheusHandler extends HttpHandlerBase { static final String VALUES_PATH = V1_PATH + "/values"; private final ValuesFetcher valuesFetcher; + private final NodeMetricGatherer nodeMetricGatherer; @Inject public PrometheusHandler(Executor executor, MetricsManager metricsManager, VespaServices vespaServices, - MetricsConsumers metricsConsumers) { + MetricsConsumers metricsConsumers, + NodeMetricGatherer nodeMetricGatherer) { super(executor); valuesFetcher = new ValuesFetcher(metricsManager, vespaServices, metricsConsumers); + this.nodeMetricGatherer = nodeMetricGatherer; } @Override @@ -50,7 +55,8 @@ public class PrometheusHandler extends HttpHandlerBase { private TextResponse valuesResponse(String consumer) { try { - List<MetricsPacket> metrics = valuesFetcher.fetch(consumer); + List<MetricsPacket> metrics = new ArrayList<>(valuesFetcher.fetch(consumer)); + metrics.addAll(nodeMetricGatherer.gatherMetrics()); return new TextResponse(OK, toPrometheusModel(metrics).serialize()); } catch (Exception e) { log.log(Level.WARNING, "Got exception when rendering metrics:", e); diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandlerTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandlerTest.java index d6bde07d39a..e49a3c2bf50 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandlerTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/prometheus/PrometheusHandlerTest.java @@ -2,6 +2,7 @@ package ai.vespa.metricsproxy.http.prometheus; import ai.vespa.metricsproxy.http.HttpHandlerTestBase; +import ai.vespa.metricsproxy.node.NodeMetricGatherer; import ai.vespa.metricsproxy.service.DummyService; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -35,7 +36,8 @@ public class PrometheusHandlerTest extends HttpHandlerTestBase { PrometheusHandler handler = new PrometheusHandler(Executors.newSingleThreadExecutor(), getMetricsManager(), vespaServices, - getMetricsConsumers()); + getMetricsConsumers(), + getNodeMetricGatherer()); testDriver = new RequestHandlerTestDriver(handler); valuesResponse = testDriver.sendRequest(VALUES_URI).readAll(); } @@ -92,4 +94,8 @@ public class PrometheusHandlerTest extends HttpHandlerTestBase { } throw new IllegalArgumentException("No line containing string: " + searchString); } + + private static NodeMetricGatherer getNodeMetricGatherer() { + return new NodeMetricGatherer(getMetricsManager(), getApplicationDimensions(), getNodeDimensions()); + } } |