in validator/src/main/java/com/amazon/aoc/validators/CWMetricValidator.java [65:115]
public void validate() throws Exception {
log.info("Start metric validating");
// get expected metrics and remove the to be skipped dimensions
final List<Metric> expectedMetricList = cwMetricHelper.listExpectedMetrics(
context,
expectedMetric,
caller
);
Set<String> skippedDimensionNameList = new HashSet<>();
for (Metric metric : expectedMetricList) {
for (Dimension dimension : metric.getDimensions()) {
if (dimension.getValue() == null || dimension.getValue().equals("")) {
continue;
}
if (dimension.getValue().equals("SKIP")) {
skippedDimensionNameList.add(dimension.getName());
}
}
}
for (Metric metric : expectedMetricList) {
metric
.getDimensions()
.removeIf((dimension) -> skippedDimensionNameList.contains(dimension.getName()));
}
// get metric from cloudwatch
RetryHelper.retry(
maxRetryCount,
() -> {
List<Metric> metricList =
this.listMetricFromCloudWatch(cloudWatchService, expectedMetricList);
// remove the skip dimensions
log.info("dimensions to be skipped in validation: {}", skippedDimensionNameList);
for (Metric metric : metricList) {
metric
.getDimensions()
.removeIf((dimension) -> skippedDimensionNameList.contains(dimension.getName()));
}
log.info("check if all the expected metrics are found");
compareMetricLists(expectedMetricList, metricList);
log.info("check if there're unexpected additional metric getting fetched");
compareMetricLists(metricList, expectedMetricList);
});
log.info("finish metric validation");
}