@Override
    public CompletableFuture<MetricsResponse> fetchMetrics(ApplicationId application) {
        NodeList applicationNodes = nodeRepository.nodes().list().owner(application).state(Node.State.active);

        Optional<Node> metricsV2Container = applicationNodes.container()
                .matching(this::expectedUp)
                .stream()
                .filter(node -> ! newNode(node)) // Skip newly added nodes, as they may not be reachable
                .findFirst();

        if (metricsV2Container.isEmpty()) {
            return CompletableFuture.completedFuture(MetricsResponse.empty());
        }
        else {
            // Collector 'autoscaling' defined in com.yahoo.vespa.model.admin.monitoring.MetricConsumer
            String url = "http://" + metricsV2Container.get().hostname() + ":" + 4080 + apiPath + "?consumer=autoscaling";
            return httpClient.get(url)
                             .thenApply(response -> new MetricsResponse(response, applicationNodes));
        }
    }
Fetches node metrics over the metrics/v2 API

@author bratseth
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/MetricsV2MetricsFetcher.java