diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/ConsumersConfigGenerator.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/ConsumersConfigGenerator.java index 29d1b557c49f..b2ab7e19f854 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/ConsumersConfigGenerator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/ConsumersConfigGenerator.java @@ -66,7 +66,7 @@ private static Metric combineMetrics(@Nullable Metric original, Metric newMetric return original != null ? newMetric.addDimensionsFrom(original) : newMetric; } - private static Consumer.Builder toConsumerBuilder(MetricsConsumer consumer) { + static Consumer.Builder toConsumerBuilder(MetricsConsumer consumer) { Consumer.Builder builder = new Consumer.Builder().name(consumer.getId()); consumer.getMetrics().values().forEach(metric -> builder.metric(toConsumerMetricBuilder(metric))); return builder; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java index 5a41696c6f2a..f290911c6bd9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerCluster.java @@ -41,12 +41,14 @@ import static com.yahoo.vespa.model.admin.metricsproxy.ConsumersConfigGenerator.addMetrics; import static com.yahoo.vespa.model.admin.metricsproxy.ConsumersConfigGenerator.generateConsumers; +import static com.yahoo.vespa.model.admin.metricsproxy.ConsumersConfigGenerator.toConsumerBuilder; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.AppDimensionNames.APPLICATION; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.AppDimensionNames.APPLICATION_ID; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.AppDimensionNames.INSTANCE; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.AppDimensionNames.LEGACY_APPLICATION; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.AppDimensionNames.TENANT; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyContainerCluster.AppDimensionNames.ZONE; +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicConsumer.getDefaultPublicConsumer; import static com.yahoo.vespa.model.admin.monitoring.VespaMetricsConsumer.getVespaMetricsConsumer; import static com.yahoo.vespa.model.admin.monitoring.MetricSet.emptyMetricSet; import static com.yahoo.vespa.model.container.xml.BundleMapper.JarSuffix.JAR_WITH_DEPS; @@ -128,8 +130,10 @@ public void getConfig(MonitoringConfig.Builder builder) { @Override public void getConfig(ConsumersConfig.Builder builder) { - var amendedDefaultConsumer = addMetrics(getVespaMetricsConsumer(), getAdditionalDefaultMetrics().getMetrics()); - builder.consumer.addAll(generateConsumers(amendedDefaultConsumer, getUserMetricsConsumers())); + var amendedVespaConsumer = addMetrics(getVespaMetricsConsumer(), getAdditionalDefaultMetrics().getMetrics()); + builder.consumer.addAll(generateConsumers(amendedVespaConsumer, getUserMetricsConsumers())); + + if (! isHostedVespa()) builder.consumer.add(toConsumerBuilder(getDefaultPublicConsumer())); } @Override diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultPublicConsumer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultPublicConsumer.java new file mode 100644 index 000000000000..fbd1c7455ddd --- /dev/null +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultPublicConsumer.java @@ -0,0 +1,32 @@ +/* + * Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + */ + +package com.yahoo.vespa.model.admin.monitoring; + +import ai.vespa.metricsproxy.http.GenericMetricsHandler; +import com.google.common.collect.ImmutableList; + +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicMetrics.defaultPublicMetricSet; +import static com.yahoo.vespa.model.admin.monitoring.DefaultVespaMetrics.defaultVespaMetricSet; +import static com.yahoo.vespa.model.admin.monitoring.SystemMetrics.systemMetricSet; +import static java.util.Collections.emptyList; + +/** + * @author gjoranv + */ +public class DefaultPublicConsumer { + + public static final String DEFAULT_PUBLIC_CONSUMER_ID = GenericMetricsHandler.DEFAULT_PUBLIC_CONSUMER_ID.id; + + private static final MetricSet publicConsumerMetrics = new MetricSet("public-consumer-metrics", + emptyList(), + ImmutableList.of(defaultPublicMetricSet, + defaultVespaMetricSet, + systemMetricSet)); + + public static MetricsConsumer getDefaultPublicConsumer() { + return new MetricsConsumer(DEFAULT_PUBLIC_CONSUMER_ID, publicConsumerMetrics); + } + +} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultPublicMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultPublicMetrics.java new file mode 100644 index 000000000000..dc2501794602 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/DefaultPublicMetrics.java @@ -0,0 +1,69 @@ +/* + * Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + */ + +package com.yahoo.vespa.model.admin.monitoring; + + +import com.google.common.collect.ImmutableSet; + +import java.util.LinkedHashSet; +import java.util.Set; + +import static java.util.Collections.emptyList; + +/** + * TODO: Add content metrics. + * + * @author gjoranv + */ +public class DefaultPublicMetrics { + + public static MetricSet defaultPublicMetricSet = createMetricSet(); + + private static MetricSet createMetricSet() { + return new MetricSet("public", + getAllMetrics(), + emptyList()); + } + + private static Set getAllMetrics() { + return ImmutableSet.builder() + .addAll(getContainerMetrics()) + .addAll(getQrserverMetrics()) + .build(); + } + + private static Set getContainerMetrics() { + Set metrics = new LinkedHashSet<>(); + + metrics.add(new Metric("http.status.1xx.rate")); + metrics.add(new Metric("http.status.2xx.rate")); + metrics.add(new Metric("http.status.3xx.rate")); + metrics.add(new Metric("http.status.4xx.rate")); + metrics.add(new Metric("http.status.5xx.rate")); + metrics.add(new Metric("jdisc.gc.ms.average")); + metrics.add(new Metric("mem.heap.free.average")); + + return metrics; + } + + private static Set getQrserverMetrics() { + Set metrics = new LinkedHashSet<>(); + + metrics.add(new Metric("queries.rate")); + metrics.add(new Metric("query_latency.average")); + metrics.add(new Metric("query_latency.95percentile")); + metrics.add(new Metric("query_latency.99percentile")); + metrics.add(new Metric("hits_per_query.average")); + metrics.add(new Metric("totalhits_per_query.average")); + metrics.add(new Metric("degraded_queries.rate")); + metrics.add(new Metric("failed_queries.rate")); + metrics.add(new Metric("serverActiveThreads.average")); + + return metrics; + } + + private DefaultPublicMetrics() { } + +} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java index b49fd36da78e..cce2891df767 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/SystemMetrics.java @@ -8,7 +8,6 @@ /** * @author gjoranv */ -@SuppressWarnings("UnusedDeclaration") // Used by model amenders public class SystemMetrics { public static final String CPU_UTIL = "cpu.util"; public static final String CPU_SYS_UTIL = "cpu.sys.util"; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java index 0749df8ddf21..ca29e348094a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricSet.java @@ -13,7 +13,6 @@ * * @author gjoranv */ -@SuppressWarnings("UnusedDeclaration") // Used by model amenders public class VespaMetricSet { public static final MetricSet vespaMetricSet = new MetricSet("vespa", diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricsConsumer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricsConsumer.java index 81e9cfcd6a0a..9f3bfdc8ae8e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricsConsumer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/VespaMetricsConsumer.java @@ -10,7 +10,7 @@ import static java.util.Collections.emptyList; /** - * This class sets up the 'Vespa' metrics consumer. + * This class sets up the 'Vespa' metrics consumer, which is mainly used for Yamas in hosted Vespa. * * @author trygve * @author gjoranv @@ -19,14 +19,14 @@ public class VespaMetricsConsumer { public static final String VESPA_CONSUMER_ID = VespaMetrics.VESPA_CONSUMER_ID.id; - private static final MetricSet defaultConsumerMetrics = new MetricSet("vespa-consumer-metrics", - emptyList(), - ImmutableList.of(vespaMetricSet, - systemMetricSet, - networkMetricSet)); + private static final MetricSet vespaConsumerMetrics = new MetricSet("vespa-consumer-metrics", + emptyList(), + ImmutableList.of(vespaMetricSet, + systemMetricSet, + networkMetricSet)); public static MetricsConsumer getVespaMetricsConsumer() { - return new MetricsConsumer(VESPA_CONSUMER_ID, defaultConsumerMetrics); + return new MetricsConsumer(VESPA_CONSUMER_ID, vespaConsumerMetrics); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/PredefinedMetricSets.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/PredefinedMetricSets.java index 4638353f39fe..694108d4bb12 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/PredefinedMetricSets.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/PredefinedMetricSets.java @@ -7,6 +7,7 @@ import java.util.LinkedHashMap; import java.util.Map; +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicMetrics.defaultPublicMetricSet; import static com.yahoo.vespa.model.admin.monitoring.NetworkMetrics.networkMetricSet; import static com.yahoo.vespa.model.admin.monitoring.SystemMetrics.systemMetricSet; import static com.yahoo.vespa.model.admin.monitoring.DefaultVespaMetrics.defaultVespaMetricSet; @@ -20,6 +21,7 @@ public class PredefinedMetricSets { public static final Map predefinedMetricSets = toMapById( + defaultPublicMetricSet, defaultVespaMetricSet, vespaMetricSet, systemMetricSet, @@ -28,8 +30,11 @@ public class PredefinedMetricSets { private static Map toMapById(MetricSet... metricSets) { Map availableMetricSets = new LinkedHashMap<>(); - for (MetricSet metricSet : metricSets) - availableMetricSets.put(metricSet.getId(), metricSet); + for (MetricSet metricSet : metricSets) { + var existing = availableMetricSets.put(metricSet.getId(), metricSet); + if (existing != null) + throw new IllegalArgumentException("There are two predefined metric sets with id " + existing.getId()); + } return Collections.unmodifiableMap(availableMetricSets); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java index 0ad0d57c1c30..b13fa4917e4b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java @@ -14,6 +14,7 @@ import java.util.Map; import java.util.stream.Collectors; +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicConsumer.DEFAULT_PUBLIC_CONSUMER_ID; import static com.yahoo.vespa.model.admin.monitoring.VespaMetricsConsumer.VESPA_CONSUMER_ID; import static com.yahoo.vespa.model.admin.monitoring.DefaultVespaMetrics.defaultVespaMetricSet; import static com.yahoo.vespa.model.admin.monitoring.SystemMetrics.systemMetricSet; @@ -77,6 +78,10 @@ private static String metricSetId(String consumerName) { private void throwIfIllegalConsumerId(Metrics metrics, String consumerId) { if (consumerId.equalsIgnoreCase(VESPA_CONSUMER_ID) && applicationType != ApplicationType.HOSTED_INFRASTRUCTURE) throw new IllegalArgumentException("'Vespa' is not allowed as metrics consumer id (case is ignored.)"); + + if (consumerId.equalsIgnoreCase(DEFAULT_PUBLIC_CONSUMER_ID)) + throw new IllegalArgumentException("'" + DEFAULT_PUBLIC_CONSUMER_ID + "' is not allowed as metrics consumer id (case is ignored.)"); + if (metrics.hasConsumerIgnoreCase(consumerId)) throw new IllegalArgumentException("'" + consumerId + "' is used as id for two metrics consumers (case is ignored.)"); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java index ff38a184eece..78c1c5931a24 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerClusterTest.java @@ -25,14 +25,17 @@ import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.MY_APPLICATION; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.MY_INSTANCE; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.MY_TENANT; +import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.hosted; +import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.self_hosted; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.checkMetric; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.consumersConfigFromModel; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.consumersConfigFromXml; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getApplicationDimensionsConfig; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getCustomConsumer; -import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getHostedModel; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getModel; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getQrStartConfig; +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicConsumer.DEFAULT_PUBLIC_CONSUMER_ID; +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicMetrics.defaultPublicMetricSet; import static com.yahoo.vespa.model.admin.monitoring.VespaMetricsConsumer.VESPA_CONSUMER_ID; import static com.yahoo.vespa.model.admin.monitoring.DefaultVespaMetrics.defaultVespaMetricSet; import static com.yahoo.vespa.model.admin.monitoring.NetworkMetrics.networkMetricSet; @@ -54,14 +57,14 @@ public class MetricsProxyContainerClusterTest { private static int numVespaMetrics = vespaMetricSet.getMetrics().size(); private static int numSystemMetrics = systemMetricSet.getMetrics().size(); private static int numNetworkMetrics = networkMetricSet.getMetrics().size(); - private static int numMetricsForDefaultConsumer = numVespaMetrics + numSystemMetrics + numNetworkMetrics; + private static int numMetricsForVespaConsumer = numVespaMetrics + numSystemMetrics + numNetworkMetrics; @Rule public ExpectedException thrown = ExpectedException.none(); @Test public void metrics_proxy_bundle_is_included_in_bundles_config() { - VespaModel model = getModel(servicesWithAdminOnly()); + VespaModel model = getModel(servicesWithAdminOnly(), self_hosted); var builder = new BundlesConfig.Builder(); model.getConfig(builder, CLUSTER_CONFIG_ID); BundlesConfig config = builder.build(); @@ -71,7 +74,7 @@ public void metrics_proxy_bundle_is_included_in_bundles_config() { @Test public void cluster_is_prepared_so_that_application_metadata_config_is_produced() { - VespaModel model = getModel(servicesWithAdminOnly()); + VespaModel model = getModel(servicesWithAdminOnly(), self_hosted); var builder = new ApplicationMetadataConfig.Builder(); model.getConfig(builder, CLUSTER_CONFIG_ID); ApplicationMetadataConfig config = builder.build(); @@ -82,26 +85,44 @@ public void cluster_is_prepared_so_that_application_metadata_config_is_produced( @Test public void verbose_gc_logging_is_disabled() { - VespaModel model = getModel(servicesWithAdminOnly()); + VespaModel model = getModel(servicesWithAdminOnly(), self_hosted); QrStartConfig config = getQrStartConfig(model); assertFalse(config.jvm().verbosegc()); } + + @Test + public void default_public_consumer_is_set_up_for_self_hosted() { + ConsumersConfig config = consumersConfigFromXml(servicesWithAdminOnly(), self_hosted); + assertEquals(2, config.consumer().size()); + assertEquals(config.consumer(1).name(), DEFAULT_PUBLIC_CONSUMER_ID); + + int numMetricsForPublicDefaultConsumer = defaultPublicMetricSet.getMetrics().size() + numDefaultVespaMetrics + numSystemMetrics; + assertEquals(numMetricsForPublicDefaultConsumer, config.consumer(1).metric().size()); + } + @Test - public void default_consumer_is_always_present_and_has_all_vespa_metrics_and_all_system_metrics() { - ConsumersConfig config = consumersConfigFromXml(servicesWithAdminOnly()); + public void default_public_consumer_is_not_set_up_for_hosted() { + ConsumersConfig config = consumersConfigFromXml(servicesWithAdminOnly(), hosted); + assertEquals(1, config.consumer().size()); assertEquals(config.consumer(0).name(), VESPA_CONSUMER_ID); - assertEquals(numMetricsForDefaultConsumer, config.consumer(0).metric().size()); } @Test - public void default_consumer_can_be_amended_via_admin_object() { - VespaModel model = getModel(servicesWithAdminOnly()); + public void vespa_consumer_is_always_present_and_has_all_vespa_metrics_and_all_system_metrics() { + ConsumersConfig config = consumersConfigFromXml(servicesWithAdminOnly(), self_hosted); + assertEquals(config.consumer(0).name(), VESPA_CONSUMER_ID); + assertEquals(numMetricsForVespaConsumer, config.consumer(0).metric().size()); + } + + @Test + public void vespa_consumer_can_be_amended_via_admin_object() { + VespaModel model = getModel(servicesWithAdminOnly(), self_hosted); var additionalMetric = new Metric("additional-metric"); model.getAdmin().setAdditionalDefaultMetrics(new MetricSet("amender-metrics", singleton(additionalMetric))); ConsumersConfig config = consumersConfigFromModel(model); - assertEquals(numMetricsForDefaultConsumer + 1, config.consumer(0).metric().size()); + assertEquals(numMetricsForVespaConsumer + 1, config.consumer(0).metric().size()); ConsumersConfig.Consumer vespaConsumer = config.consumer(0); assertTrue("Did not contain additional metric", checkMetric(vespaConsumer, additionalMetric)); @@ -109,19 +130,28 @@ public void default_consumer_can_be_amended_via_admin_object() { @Test public void vespa_is_a_reserved_consumer_id() { + assertReservedConsumerId("Vespa"); + } + + @Test + public void public_is_a_reserved_consumer_id() { + assertReservedConsumerId("default"); + } + + private void assertReservedConsumerId(String consumerId) { String services = String.join("\n", - "", - " ", - " ", - " ", - " ", - " ", - " ", - "" + "", + " ", + " ", + " ", + " ", + " ", + " ", + "" ); thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("'Vespa' is not allowed as metrics consumer id"); - consumersConfigFromXml(services); + thrown.expectMessage("'" + consumerId + "' is not allowed as metrics consumer id"); + consumersConfigFromXml(services, self_hosted); } @Test @@ -138,12 +168,13 @@ public void vespa_consumer_id_is_allowed_for_hosted_infrastructure_applications( " ", "" ); - ConsumersConfig config = consumersConfigFromXml(services); + VespaModel hostedModel = getModel(services, hosted); + ConsumersConfig config = consumersConfigFromModel(hostedModel); assertEquals(1, config.consumer().size()); // All default metrics are retained ConsumersConfig.Consumer vespaConsumer = config.consumer(0); - assertEquals(numMetricsForDefaultConsumer + 1, vespaConsumer.metric().size()); + assertEquals(numMetricsForVespaConsumer + 1, vespaConsumer.metric().size()); Metric customMetric1 = new Metric("custom.metric1"); assertTrue("Did not contain metric: " + customMetric1, checkMetric(vespaConsumer, customMetric1)); @@ -164,7 +195,7 @@ public void consumer_id_is_case_insensitive() { ); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("'a' is used as id for two metrics consumers"); - consumersConfigFromXml(services); + consumersConfigFromXml(services, self_hosted); } @Test @@ -216,7 +247,7 @@ public void consumer_with_vespa_metric_set_has_all_vespa_metrics_plus_all_system @Test public void hosted_application_propagates_application_dimensions() { - VespaModel hostedModel = getHostedModel(servicesWithAdminOnly()); + VespaModel hostedModel = getModel(servicesWithAdminOnly(), hosted); ApplicationDimensionsConfig config = getApplicationDimensionsConfig(hostedModel); assertEquals(zoneString(Zone.defaultZone()), config.dimensions(AppDimensionNames.ZONE)); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java index f755871ac4b0..5d3bcd58f3d5 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyContainerTest.java @@ -11,7 +11,8 @@ import static com.yahoo.config.model.api.container.ContainerServiceType.METRICS_PROXY_CONTAINER; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.CLUSTER_CONFIG_ID; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.CONTAINER_CONFIG_ID; -import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getHostedModel; +import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.hosted; +import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.self_hosted; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getModel; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getNodeDimensionsConfig; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getRpcConnectorConfig; @@ -49,7 +50,7 @@ public void one_metrics_proxy_container_is_added_to_every_node() { @Test public void metrics_proxy_requires_less_memory_than_other_containers() { - VespaModel model = getModel(servicesWithContent()); + VespaModel model = getModel(servicesWithContent(), self_hosted); MetricsProxyContainer container = (MetricsProxyContainer)model.id2producer().get(CONTAINER_CONFIG_ID); assertThat(container.getStartupCommand(), containsString("-Xms32m")); assertThat(container.getStartupCommand(), containsString("-Xmx512m")); @@ -57,7 +58,7 @@ public void metrics_proxy_requires_less_memory_than_other_containers() { @Test public void http_server_is_running_on_expected_port() { - VespaModel model = getModel(servicesWithContent()); + VespaModel model = getModel(servicesWithContent(), self_hosted); MetricsProxyContainer container = (MetricsProxyContainer)model.id2producer().get(CONTAINER_CONFIG_ID); assertEquals(19092, container.getSearchPort()); assertEquals(19092, container.getHealthPort()); @@ -69,7 +70,7 @@ public void http_server_is_running_on_expected_port() { @Test public void metrics_rpc_server_is_running_on_expected_port() { - VespaModel model = getModel(servicesWithContent()); + VespaModel model = getModel(servicesWithContent(), self_hosted); MetricsProxyContainer container = (MetricsProxyContainer)model.id2producer().get(CONTAINER_CONFIG_ID); int offset = container.metricsRpcPortOffset(); @@ -85,7 +86,7 @@ public void metrics_rpc_server_is_running_on_expected_port() { @Test public void admin_rpc_server_is_running() { - VespaModel model = getModel(servicesWithContent()); + VespaModel model = getModel(servicesWithContent(), self_hosted); MetricsProxyContainer container = (MetricsProxyContainer)model.id2producer().get(CONTAINER_CONFIG_ID); int offset = container.metricsRpcPortOffset() - 1; @@ -99,7 +100,7 @@ public void admin_rpc_server_is_running() { @Test public void hosted_application_propagates_node_dimensions() { String services = servicesWithContent(); - VespaModel hostedModel = getHostedModel(services); + VespaModel hostedModel = getModel(services, hosted); assertEquals(1, hostedModel.getHosts().size()); String configId = CLUSTER_CONFIG_ID + "/" + hostedModel.getHosts().iterator().next().getHostname(); NodeDimensionsConfig config = getNodeDimensionsConfig(hostedModel, configId); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyModelTester.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyModelTester.java index 59b7110e96ed..ad6a7de935bd 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyModelTester.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsProxyModelTester.java @@ -16,6 +16,9 @@ import com.yahoo.vespa.model.admin.monitoring.Metric; import com.yahoo.vespa.model.test.VespaModelTester; +import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.hosted; +import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.TestMode.self_hosted; +import static com.yahoo.vespa.model.admin.monitoring.DefaultPublicConsumer.DEFAULT_PUBLIC_CONSUMER_ID; import static com.yahoo.vespa.model.admin.monitoring.VespaMetricsConsumer.VESPA_CONSUMER_ID; import static org.junit.Assert.assertEquals; @@ -33,20 +36,17 @@ class MetricsProxyModelTester { // Used for all configs that are produced by the container, not the cluster. static final String CONTAINER_CONFIG_ID = CLUSTER_CONFIG_ID + "/localhost"; - static VespaModel getModel(String servicesXml) { - var numberOfHosts = 1; - var tester = new VespaModelTester(); - tester.addHosts(numberOfHosts); - tester.setHosted(false); - return tester.createModel(servicesXml, true); + enum TestMode { + self_hosted, + hosted } - static VespaModel getHostedModel(String servicesXml) { - var numberOfHosts = 2; + static VespaModel getModel(String servicesXml, TestMode testMode) { + var numberOfHosts = testMode == hosted ? 2 : 1; var tester = new VespaModelTester(); tester.addHosts(numberOfHosts); - tester.setHosted(true); - tester.setApplicationId(MY_TENANT, MY_APPLICATION, MY_INSTANCE); + tester.setHosted(testMode == hosted); + if (testMode == hosted) tester.setApplicationId(MY_TENANT, MY_APPLICATION, MY_INSTANCE); return tester.createModel(servicesXml, true); } @@ -59,17 +59,16 @@ static boolean checkMetric(ConsumersConfig.Consumer consumer, Metric metric) { } static ConsumersConfig.Consumer getCustomConsumer(String servicesXml) { - ConsumersConfig config = consumersConfigFromXml(servicesXml); - assertEquals(2, config.consumer().size()); + ConsumersConfig config = consumersConfigFromXml(servicesXml, self_hosted); for (ConsumersConfig.Consumer consumer : config.consumer()) { - if (! consumer.name().equals(VESPA_CONSUMER_ID)) + if (! consumer.name().equals(VESPA_CONSUMER_ID) && ! consumer.name().equals(DEFAULT_PUBLIC_CONSUMER_ID)) return consumer; } - throw new RuntimeException("Two consumers with the reserved id - this cannot happen."); + throw new RuntimeException("Custom consumer not found!"); } - static ConsumersConfig consumersConfigFromXml(String servicesXml) { - return consumersConfigFromModel(getModel(servicesXml)); + static ConsumersConfig consumersConfigFromXml(String servicesXml, TestMode testMode) { + return consumersConfigFromModel(getModel(servicesXml, testMode)); } static ConsumersConfig consumersConfigFromModel(VespaModel model) { @@ -89,7 +88,7 @@ static NodeDimensionsConfig getNodeDimensionsConfig(VespaModel model, String con } static VespaServicesConfig getVespaServicesConfig(String servicesXml) { - VespaModel model = getModel(servicesXml); + VespaModel model = getModel(servicesXml, self_hosted); return new VespaServicesConfig((VespaServicesConfig.Builder) model.getConfig(new VespaServicesConfig.Builder(), CONTAINER_CONFIG_ID)); } diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/core/VespaMetrics.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/core/VespaMetrics.java index 2ca24dad1e28..ab9f4f6c9c4d 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/core/VespaMetrics.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/core/VespaMetrics.java @@ -117,7 +117,8 @@ private MetricsPacket.Builder getHealth(VespaService service) { .statusCode(health.getStatus().ordinal()) // TODO: MetricsPacket should use StatusCode instead of int .statusMessage(health.getMessage()) .putDimensions(service.getDimensions()) - .putDimension(INSTANCE_DIMENSION_ID, service.getInstanceName()); + .putDimension(INSTANCE_DIMENSION_ID, service.getInstanceName()) + .addConsumers(metricsConsumers.getAllConsumers()); } /** diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/GenericMetricsHandler.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/GenericMetricsHandler.java index cadfc053b948..f61a96917a91 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/GenericMetricsHandler.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/GenericMetricsHandler.java @@ -4,7 +4,9 @@ package ai.vespa.metricsproxy.http; +import ai.vespa.metricsproxy.core.MetricsConsumers; import ai.vespa.metricsproxy.core.MetricsManager; +import ai.vespa.metricsproxy.metric.model.ConsumerId; import ai.vespa.metricsproxy.metric.model.MetricsPacket; import ai.vespa.metricsproxy.metric.model.json.JsonRenderingException; import ai.vespa.metricsproxy.service.VespaServices; @@ -19,22 +21,33 @@ import java.time.Instant; import java.util.List; import java.util.concurrent.Executor; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import static ai.vespa.metricsproxy.metric.model.ConsumerId.toConsumerId; import static ai.vespa.metricsproxy.metric.model.json.GenericJsonUtil.toGenericJsonModel; /** - * Handler exposing the generic metrics format via http. + * Http handler that exposes the generic metrics format. * * @author gjoranv */ public class GenericMetricsHandler extends ThreadedHttpRequestHandler { + private static final Logger log = Logger.getLogger(GenericMetricsHandler.class.getName()); + public static final ConsumerId DEFAULT_PUBLIC_CONSUMER_ID = toConsumerId("default"); + + private final MetricsConsumers metricsConsumers; private final MetricsManager metricsManager; private final VespaServices vespaServices; @Inject - public GenericMetricsHandler(Executor executor, MetricsManager metricsManager, VespaServices vespaServices) { + public GenericMetricsHandler(Executor executor, + MetricsManager metricsManager, + VespaServices vespaServices, + MetricsConsumers metricsConsumers) { super(executor); + this.metricsConsumers = metricsConsumers; this.metricsManager = metricsManager; this.vespaServices = vespaServices; } @@ -42,13 +55,29 @@ public GenericMetricsHandler(Executor executor, MetricsManager metricsManager, V @Override public HttpResponse handle(HttpRequest request) { try { - List metrics = metricsManager.getMetrics(vespaServices.getVespaServices(), Instant.now()); + ConsumerId consumer = getConsumerOrDefault(request.getProperty("consumer")); + + List metrics = metricsManager.getMetrics(vespaServices.getVespaServices(), Instant.now()) + .stream() + .filter(metricsPacket -> metricsPacket.consumers().contains(consumer)) + .collect(Collectors.toList()); return new Response(200, toGenericJsonModel(metrics).serialize()); } catch (JsonRenderingException e) { return new Response(500, e.getMessageAsJson()); } } + private ConsumerId getConsumerOrDefault(String consumer) { + if (consumer == null) return DEFAULT_PUBLIC_CONSUMER_ID; + + ConsumerId consumerId = toConsumerId(consumer); + if (! metricsConsumers.getAllConsumers().contains(consumerId)) { + log.info("No consumer with id '" + consumer + "' - using the default consumer instead."); + return DEFAULT_PUBLIC_CONSUMER_ID; + } + return consumerId; + } + private static class Response extends HttpResponse { private final byte[] data; diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/ExternalMetrics.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/ExternalMetrics.java index 26ae177d7670..64ede137e8e7 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/ExternalMetrics.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/metric/ExternalMetrics.java @@ -53,6 +53,8 @@ public List getMetrics() { } public void setExtraMetrics(List externalPackets) { + // TODO: Metrics filtering per consumer is not yet implemented. + // Split each packet per metric, and re-aggregate based on the metrics each consumer wants. Then filter out all packages with no consumers. log.log(DEBUG, () -> "Setting new external metrics with " + externalPackets.size() + " metrics packets."); externalPackets.forEach(packet -> { packet.addConsumers(consumers.getAllConsumers()) diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java index eb620fd37be5..e441c3532929 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/core/MetricsManagerTest.java @@ -140,6 +140,7 @@ public void system_metrics_are_added() { service0.setSystemMetrics(oldSystemMetrics); } + // TODO: test that non-whitelisted metrics are filtered out, but this is currently not the case, see ExternalMetrics.setExtraMetrics @Test public void extra_metrics_packets_containing_whitelisted_metrics_are_added() { metricsManager.setExtraMetrics(ImmutableList.of( diff --git a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/GenericMetricsHandlerTest.java b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/GenericMetricsHandlerTest.java index 301dbf56c3f5..29ab8c666948 100644 --- a/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/GenericMetricsHandlerTest.java +++ b/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/GenericMetricsHandlerTest.java @@ -6,6 +6,7 @@ import ai.vespa.metricsproxy.TestUtil; import ai.vespa.metricsproxy.core.ConsumersConfig; +import ai.vespa.metricsproxy.core.ConsumersConfig.Consumer; import ai.vespa.metricsproxy.core.MetricsConsumers; import ai.vespa.metricsproxy.core.MetricsManager; import ai.vespa.metricsproxy.metric.HealthMetric; @@ -29,12 +30,13 @@ import org.junit.Ignore; import org.junit.Test; +import java.io.IOException; import java.time.Instant; import java.util.List; import java.util.concurrent.Executors; import static ai.vespa.metricsproxy.core.VespaMetrics.INSTANCE_DIMENSION_ID; -import static ai.vespa.metricsproxy.core.VespaMetrics.VESPA_CONSUMER_ID; +import static ai.vespa.metricsproxy.http.GenericMetricsHandler.DEFAULT_PUBLIC_CONSUMER_ID; import static ai.vespa.metricsproxy.metric.model.ServiceId.toServiceId; import static ai.vespa.metricsproxy.metric.model.StatusCode.DOWN; import static ai.vespa.metricsproxy.metric.model.json.JacksonUtil.createObjectMapper; @@ -43,6 +45,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; /** * @author gjoranv @@ -55,38 +58,69 @@ public class GenericMetricsHandlerTest { new DummyService(1, ""), new DownService(HealthMetric.getDown("No response"))); + private static final VespaServices vespaServices = new VespaServices(testServices); + + private static final String DEFAULT_CONSUMER = "default"; + private static final String CUSTOM_CONSUMER = "custom-consumer"; + private static final String CPU_METRIC = "cpu"; private static final String URI = "http://localhost/metrics/v1/values"; - private static final VespaServices vespaServices = new VespaServices(testServices); private static RequestHandlerTestDriver testDriver; @BeforeClass - public static void setupMetricsManager() { + public static void setup() { MetricsManager metricsManager = TestUtil.createMetricsManager(vespaServices, getMetricsConsumers(), getApplicationDimensions(), getNodeDimensions()); metricsManager.setExtraMetrics(ImmutableList.of( new MetricsPacket.Builder(toServiceId("foo")) .timestamp(Instant.now().getEpochSecond()) .putMetrics(ImmutableList.of(new Metric(CPU_METRIC, 12.345))))); - GenericMetricsHandler handler = new GenericMetricsHandler(Executors.newSingleThreadExecutor(), metricsManager, vespaServices); + GenericMetricsHandler handler = new GenericMetricsHandler(Executors.newSingleThreadExecutor(), metricsManager, vespaServices, getMetricsConsumers()); testDriver = new RequestHandlerTestDriver(handler); } + private GenericJsonModel getResponseAsJsonModel(String consumer) { + String response = testDriver.sendRequest(URI + "?consumer=" + consumer).readAll(); + try { + return createObjectMapper().readValue(response, GenericJsonModel.class); + } catch (IOException e) { + fail("Failed to create json model: " + e.getMessage()); + throw new RuntimeException(e); + } + } + @Ignore @Test public void visually_inspect_response() throws Exception{ - String response = testDriver.sendRequest(URI).readAll(); + String response = testDriver.sendRequest(URI+ "?consumer=default").readAll(); ObjectMapper mapper = createObjectMapper(); var jsonModel = mapper.readValue(response, GenericJsonModel.class); System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonModel)); } @Test - public void response_contains_node_metrics() throws Exception { + public void no_explicit_consumer_gives_the_default_consumer() { + String responseDefaultConsumer = testDriver.sendRequest(URI + "?consumer=default").readAll(); + String responseNoConsumer = testDriver.sendRequest(URI).readAll(); + assertEqualsExceptTimestamps(responseDefaultConsumer, responseNoConsumer); + } + + @Test + public void unknown_consumer_gives_the_default_consumer() { String response = testDriver.sendRequest(URI).readAll(); - var jsonModel = createObjectMapper().readValue(response, GenericJsonModel.class); + String responseUnknownConsumer = testDriver.sendRequest(URI + "?consumer=not_defined").readAll(); + assertEqualsExceptTimestamps(response, responseUnknownConsumer); + } + + private void assertEqualsExceptTimestamps(String s1, String s2) { + assertEquals(replaceTimestamps(s1), replaceTimestamps(s2)); + } + + @Test + public void response_contains_node_metrics() { + GenericJsonModel jsonModel = getResponseAsJsonModel(DEFAULT_CONSUMER); assertNotNull(jsonModel.node); assertEquals(1, jsonModel.node.metrics.size()); @@ -94,9 +128,8 @@ public void response_contains_node_metrics() throws Exception { } @Test - public void response_contains_service_metrics() throws Exception { - String response = testDriver.sendRequest(URI).readAll(); - var jsonModel = createObjectMapper().readValue(response, GenericJsonModel.class); + public void response_contains_service_metrics() { + GenericJsonModel jsonModel = getResponseAsJsonModel(DEFAULT_CONSUMER); assertEquals(2, jsonModel.services.size()); GenericService dummyService = jsonModel.services.get(0); @@ -104,17 +137,50 @@ public void response_contains_service_metrics() throws Exception { GenericMetrics dummy0Metrics = getMetricsForInstance("dummy0", dummyService); assertEquals(1L, dummy0Metrics.values.get(METRIC_1).longValue()); - assertEquals("metric-dim", dummy0Metrics.dimensions.get("dim0")); + assertEquals("default-val", dummy0Metrics.dimensions.get("consumer-dim")); GenericMetrics dummy1Metrics = getMetricsForInstance("dummy1", dummyService); assertEquals(6L, dummy1Metrics.values.get(METRIC_1).longValue()); - assertEquals("metric-dim", dummy1Metrics.dimensions.get("dim0")); + assertEquals("default-val", dummy1Metrics.dimensions.get("consumer-dim")); } @Test - public void response_contains_health_from_service_that_is_down() throws Exception { - String response = testDriver.sendRequest(URI).readAll(); - var jsonModel = createObjectMapper().readValue(response, GenericJsonModel.class); + public void all_consumers_get_health_from_service_that_is_down() { + assertDownServiceHealth(DEFAULT_CONSUMER); + assertDownServiceHealth(CUSTOM_CONSUMER); + } + + @Test + public void all_timestamps_are_equal_and_non_zero() { + GenericJsonModel jsonModel = getResponseAsJsonModel(DEFAULT_CONSUMER); + + Long nodeTimestamp = jsonModel.node.timestamp; + assertNotEquals(0L, (long) nodeTimestamp); + for (var service : jsonModel.services) + assertEquals(nodeTimestamp, service.timestamp); + } + + @Test + public void custom_consumer_gets_only_its_whitelisted_metrics() { + GenericJsonModel jsonModel = getResponseAsJsonModel(CUSTOM_CONSUMER); + + assertNotNull(jsonModel.node); + // TODO: see comment in ExternalMetrics.setExtraMetrics + // assertEquals(0, jsonModel.node.metrics.size()); + + assertEquals(2, jsonModel.services.size()); + GenericService dummyService = jsonModel.services.get(0); + assertEquals(2, dummyService.metrics.size()); + + GenericMetrics dummy0Metrics = getMetricsForInstance("dummy0", dummyService); + assertEquals("custom-val", dummy0Metrics.dimensions.get("consumer-dim")); + + GenericMetrics dummy1Metrics = getMetricsForInstance("dummy1", dummyService); + assertEquals("custom-val", dummy1Metrics.dimensions.get("consumer-dim")); + } + + private void assertDownServiceHealth(String consumer) { + GenericJsonModel jsonModel = getResponseAsJsonModel(consumer); GenericService downService = jsonModel.services.get(1); assertEquals(DOWN.status, downService.status.code); @@ -127,15 +193,8 @@ public void response_contains_health_from_service_that_is_down() throws Exceptio assertEquals(DownService.NAME, downService.metrics.get(0).dimensions.get(INSTANCE_DIMENSION_ID.id)); } - @Test - public void all_timestamps_are_equal_and_non_zero() throws Exception { - String response = testDriver.sendRequest(URI).readAll(); - var jsonModel = createObjectMapper().readValue(response, GenericJsonModel.class); - - Long nodeTimestamp = jsonModel.node.timestamp; - assertNotEquals(0L, (long) nodeTimestamp); - for (var service : jsonModel.services) - assertEquals(nodeTimestamp, service.timestamp); + private String replaceTimestamps(String s) { + return s.replaceAll("timestamp\":\\d+,", "timestamp\":1,"); } private static GenericMetrics getMetricsForInstance(String instance, GenericService service) { @@ -143,23 +202,33 @@ private static GenericMetrics getMetricsForInstance(String instance, GenericServ if (metrics.dimensions.get(INSTANCE_DIMENSION_ID.id).equals(instance)) return metrics; } - throw new RuntimeException("Could not find metrics for service instance " + instance); + fail("Could not find metrics for service instance " + instance); + throw new RuntimeException(); } private static MetricsConsumers getMetricsConsumers() { - ConsumersConfig.Consumer.Metric.Dimension.Builder metricDimension = new ConsumersConfig.Consumer.Metric.Dimension.Builder() - .key("dim0").value("metric-dim"); + var defaultConsumerDimension = new Consumer.Metric.Dimension.Builder() + .key("consumer-dim").value("default-val"); + + var customConsumerDimension = new Consumer.Metric.Dimension.Builder() + .key("consumer-dim").value("custom-val"); return new MetricsConsumers(new ConsumersConfig.Builder() - .consumer(new ConsumersConfig.Consumer.Builder() - .name(VESPA_CONSUMER_ID.id) - .metric(new ConsumersConfig.Consumer.Metric.Builder() + .consumer(new Consumer.Builder() + .name(DEFAULT_PUBLIC_CONSUMER_ID.id) + .metric(new Consumer.Metric.Builder() .name(CPU_METRIC) .outputname(CPU_METRIC)) - .metric(new ConsumersConfig.Consumer.Metric.Builder() + .metric(new Consumer.Metric.Builder() + .name(METRIC_1) + .outputname(METRIC_1) + .dimension(defaultConsumerDimension))) + .consumer(new Consumer.Builder() + .name(CUSTOM_CONSUMER) + .metric(new Consumer.Metric.Builder() .name(METRIC_1) .outputname(METRIC_1) - .dimension(metricDimension))) + .dimension(customConsumerDimension))) .build()); }