private static Map<ConfiguredMetric, Set<ConsumerId>>
    createConsumersByMetric(Map<ConsumerId, List<ConfiguredMetric>> metricsByConsumer) {
        Map<ConfiguredMetric, Set<ConsumerId>> consumersByMetric = new LinkedHashMap<>();
        metricsByConsumer.forEach(
                (consumer, metrics) -> metrics.forEach(
                        metric -> consumersByMetric.computeIfAbsent(metric, unused -> new HashSet<>())
                                .add(consumer)));
        Map<ConfiguredMetric, Set<ConsumerId>> unmodifiableConsumersByMetric = new LinkedHashMap<>();
        consumersByMetric.forEach((configuredMetric, consumerIds) -> unmodifiableConsumersByMetric.put(configuredMetric, Set.copyOf(consumerIds)));
        return Collections.unmodifiableMap(unmodifiableConsumersByMetric);
    }
Helper function to create mapping from metric to consumers.
TODO: consider reversing the mapping in metrics-consumers.def instead: metric{}.consumer[]
metrics-proxy/src/main/java/ai/vespa/metricsproxy/core/MetricsConsumers.java