blob: 025b78756778f4400380e38859f28499c7529c9f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.yahoo.vespa.model.application.validation;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.admin.monitoring.MetricsConsumer;
import java.util.List;
import static java.util.stream.Collectors.toList;
/**
* @author gjoranv
*/
public class CloudWatchValidator extends Validator {
@Override
public void validate(VespaModel model, DeployState deployState) {
if (!deployState.isHosted()) return;
if (deployState.zone().system().isPublic()) return;
if (model.getAdmin().getApplicationType() != ConfigModelContext.ApplicationType.DEFAULT) return;
var offendingConsumers = model.getAdmin().getUserMetrics().getConsumers().values().stream()
.filter(consumer -> !consumer.cloudWatches().isEmpty())
.collect(toList());
if (! offendingConsumers.isEmpty()) {
throw new IllegalArgumentException("CloudWatch cannot be set up for non-public hosted Vespa and must " +
"be removed for consumers: " + consumerIds(offendingConsumers));
}
}
private List<String> consumerIds(List<MetricsConsumer> offendingConsumers) {
return offendingConsumers.stream().map(MetricsConsumer::id).collect(toList());
}
}
|