Fix the exception when getting baseline for empty dimension maps
@@ -748,15 +748,18 @@ public class AnomalyResource {
String[] exploreDimensions = anomalyFunctionSpec.getExploreDimensions().split(",");
Map<String, String> inputDimension = OBJECT_MAPPER.readValue(dimension, Map.class);
DimensionMap dimensionsToBeEvaluated = new DimensionMap();
+ if (exploreDimensions != null && StringUtils.isNotBlank(anomalyFunctionSpec.getExploreDimensions())) {
for (String exploreDimension : exploreDimensions) {
if (!inputDimension.containsKey(exploreDimension)) {
- String msg = String.format("Query %s doesn't specify the value of explore dimension %s", dimension, exploreDimension);
+ String msg =
+ String.format("Query %s doesn't specify the value of explore dimension %s", dimension, exploreDimension);
LOG.error(msg);
throw new WebApplicationException(msg);
} else {
dimensionsToBeEvaluated.put(exploreDimension, inputDimension.get(exploreDimension));
}
}
+ }
// Get the anomaly time lines view of the anomaly function on each dimension
HashMap<String, AnomalyTimelinesView> dimensionMapAnomalyTimelinesViewMap = new HashMap<>();
