This is an automated email from the ASF dual-hosted git repository.

akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 0fded63  [TE] Inject Sub Entity Name into the anomaly properties 
(#4452)
0fded63 is described below

commit 0fded6321f2939ca6d525f113cfd60e4ba8b5dd1
Author: Akshay Rai <[email protected]>
AuthorDate: Mon Jul 22 14:49:37 2019 -0700

    [TE] Inject Sub Entity Name into the anomaly properties (#4452)
---
 ...er.java => EntityGroupKeyContentFormatter.java} | 15 +++++++-------
 .../pinot/thirdeye/detection/DetectionUtils.java   |  9 --------
 .../alert/scheme/DetectionEmailAlerter.java        |  4 ++--
 .../components/TriggerConditionGrouper.java        |  9 ++++----
 .../detection/wrapper/AnomalyDetectorWrapper.java  |  6 ++++++
 .../thirdeye/detection/wrapper/GrouperWrapper.java | 14 +++++++++----
 .../yaml/translator/DetectionConfigTranslator.java | 24 ++++++++++++----------
 ...port.ftl => entity-groupkey-anomaly-report.ftl} |  0
 ...> TestEntityGroupKeyEmailContentFormatter.java} | 11 +++++-----
 .../components/TriggerConditionGrouperTest.java    |  3 ++-
 .../wrapper/AnomalyDetectorWrapperTest.java        |  4 ++--
 .../compositePipelineTranslatorTestResult-1.json   |  4 +++-
 .../compositePipelineTranslatorTestResult-2.json   |  1 +
 .../compositePipelineTranslatorTestResult-4.json   |  1 +
 .../compositePipelineTranslatorTestResult-5.json   |  4 ++++
 15 files changed, 63 insertions(+), 46 deletions(-)

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/EntityGroupByContentFormatter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/EntityGroupKeyContentFormatter.java
similarity index 94%
rename from 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/EntityGroupByContentFormatter.java
rename to 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/EntityGroupKeyContentFormatter.java
index 632ec63..a799d3e 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/EntityGroupByContentFormatter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/EntityGroupKeyContentFormatter.java
@@ -39,17 +39,18 @@ import org.apache.pinot.thirdeye.util.ThirdEyeUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
+
 
 /**
  * This email formatter generates a report/alert from the anomalies having a 
groupKey
  */
-public class EntityGroupByContentFormatter extends BaseEmailContentFormatter{
-  private static final Logger LOG = 
LoggerFactory.getLogger(EntityGroupByContentFormatter.class);
+public class EntityGroupKeyContentFormatter extends BaseEmailContentFormatter{
+  private static final Logger LOG = 
LoggerFactory.getLogger(EntityGroupKeyContentFormatter.class);
 
   private static final String EMAIL_TEMPLATE = "emailTemplate";
-  private static final String DEFAULT_EMAIL_TEMPLATE = 
"entity-groupby-anomaly-report.ftl";
+  private static final String DEFAULT_EMAIL_TEMPLATE = 
"entity-groupkey-anomaly-report.ftl";
 
-  static final String PROP_ENTITY_NAME = "entityName";
   static final String PROP_ANOMALY_SCORE = "groupScore";
   static final String PROP_GROUP_KEY = "groupKey";
 
@@ -59,7 +60,7 @@ public class EntityGroupByContentFormatter extends 
BaseEmailContentFormatter{
   private Map<AnomalyReportEntity, Double> anomalyToGroupScoreMap = new 
HashMap<>();
   private Map<String, String> anomalyToChildIdsMap = new HashMap<>();
 
-  public EntityGroupByContentFormatter() {}
+  public EntityGroupKeyContentFormatter() {}
 
   @Override
   public void init(Properties properties, EmailContentFormatterConfiguration 
configuration) {
@@ -124,7 +125,7 @@ public class EntityGroupByContentFormatter extends 
BaseEmailContentFormatter{
       }
       anomalyReport.setWeight(anomaly.getWeight());
       anomalyReport.setGroupKey(anomaly.getProperties().get(PROP_GROUP_KEY));
-      
anomalyReport.setEntityName(anomaly.getProperties().getOrDefault(PROP_ENTITY_NAME,
 "UNKNOWN_ENTITY"));
+      
anomalyReport.setEntityName(anomaly.getProperties().get(PROP_SUB_ENTITY_NAME));
 
       Set<Long> childIds = new HashSet<>();
       if (anomaly.getChildIds() != null) {
@@ -138,7 +139,7 @@ public class EntityGroupByContentFormatter extends 
BaseEmailContentFormatter{
         anomalyToChildIdsMap.put(anomalyReport.getGroupKey() + 
anomalyReport.getStartDateTime(), Joiner.on(",").join(childIds));
 
         anomalyToGroupScoreMap.put(anomalyReport, score);
-        
entityToAnomaliesMap.put(anomaly.getProperties().get(PROP_ENTITY_NAME), 
anomalyReport);
+        
entityToAnomaliesMap.put(anomaly.getProperties().get(PROP_SUB_ENTITY_NAME), 
anomalyReport);
       }
     } else {
       for (MergedAnomalyResultDTO childAnomaly : anomaly.getChildren()) {
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
index c81d7ce..bb9832f 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
@@ -199,15 +199,6 @@ public class DetectionUtils {
     return entityAnomaly;
   }
 
-  public static MergedAnomalyResultDTO makeEntityCopy(MergedAnomalyResultDTO 
anomaly) {
-    MergedAnomalyResultDTO anomalyCopy = makeEntityAnomaly();
-    anomalyCopy.setStartTime(anomaly.getStartTime());
-    anomalyCopy.setEndTime(anomaly.getEndTime());
-    anomalyCopy.setChild(anomaly.isChild());
-    anomalyCopy.setChildren(anomaly.getChildren());
-    return anomalyCopy;
-  }
-
   public static MergedAnomalyResultDTO 
makeParentEntityAnomaly(MergedAnomalyResultDTO childAnomaly) {
     MergedAnomalyResultDTO newEntityAnomaly = makeEntityAnomaly();
     newEntityAnomaly.setStartTime(childAnomaly.getStartTime());
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
index 56377a9..7cef8f8 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
@@ -25,7 +25,7 @@ import org.apache.pinot.thirdeye.alert.commons.EmailEntity;
 import org.apache.pinot.thirdeye.alert.content.EmailContentFormatter;
 import 
org.apache.pinot.thirdeye.alert.content.EmailContentFormatterConfiguration;
 import org.apache.pinot.thirdeye.alert.content.EmailContentFormatterContext;
-import org.apache.pinot.thirdeye.alert.content.EntityGroupByContentFormatter;
+import org.apache.pinot.thirdeye.alert.content.EntityGroupKeyContentFormatter;
 import 
org.apache.pinot.thirdeye.alert.content.MetricAnomaliesEmailContentFormatter;
 import org.apache.pinot.thirdeye.anomaly.SmtpConfiguration;
 import org.apache.pinot.thirdeye.anomaly.ThirdEyeAnomalyConfiguration;
@@ -151,7 +151,7 @@ public class DetectionEmailAlerter extends 
DetectionAlertScheme {
         return EmailContentFormatterFactory.fromClassName(className);
 
       case ENTITY_GROUPBY_REPORT:
-        className = EntityGroupByContentFormatter.class.getSimpleName();
+        className = EntityGroupKeyContentFormatter.class.getSimpleName();
         LOG.info("Using " + className + " to render the template.");
         return EmailContentFormatterFactory.fromClassName(className);
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouper.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouper.java
index 5815cec..335764b 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouper.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouper.java
@@ -38,6 +38,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.pinot.thirdeye.detection.DetectionUtils.*;
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
 
 
 /**
@@ -54,7 +55,6 @@ public class TriggerConditionGrouper implements 
Grouper<TriggerConditionGrouperS
   private Map<String, Object> rightOp;
   private InputDataFetcher dataFetcher;
 
-  static final String PROP_ENTITY_NAME = "entityName";
   static final String PROP_AND = "and";
   static final String PROP_OR = "or";
   static final String PROP_OPERATOR = "operator";
@@ -139,12 +139,13 @@ public class TriggerConditionGrouper implements 
Grouper<TriggerConditionGrouperS
   private List<MergedAnomalyResultDTO> groupAnomaliesByOperator(Map<String, 
Object> operatorNode, List<MergedAnomalyResultDTO> anomalies) {
     Preconditions.checkNotNull(operatorNode);
 
-    // Base condition - If reached leaf node, then return the anomalies 
corresponding to the entity/metric
+    // Base condition - If reached leaf node of operator tree, then return the 
anomalies corresponding to the entity/metric
     String value = MapUtils.getString(operatorNode, "value");
     if (value != null) {
       return anomalies.stream().filter(anomaly ->
-          anomaly.getProperties() != null && 
anomaly.getProperties().get(PROP_ENTITY_NAME) != null
-              && 
anomaly.getProperties().get(PROP_ENTITY_NAME).startsWith(value)
+          anomaly.getProperties() != null
+          && anomaly.getProperties().containsKey(PROP_SUB_ENTITY_NAME)
+          && anomaly.getProperties().get(PROP_SUB_ENTITY_NAME).equals(value)
       ).collect(Collectors.toList());
     }
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapper.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapper.java
index 4f8c67b..38fbd78 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapper.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapper.java
@@ -60,6 +60,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.pinot.thirdeye.dataframe.util.DataFrameUtils.*;
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
 
 
 /**
@@ -95,6 +96,7 @@ public class AnomalyDetectorWrapper extends DetectionPipeline 
{
   private static final Logger LOG = 
LoggerFactory.getLogger(AnomalyDetectorWrapper.class);
 
   private final String metricUrn;
+  private final String entityName;
   private final AnomalyDetector anomalyDetector;
 
   private final int windowDelay;
@@ -115,6 +117,9 @@ public class AnomalyDetectorWrapper extends 
DetectionPipeline {
   public AnomalyDetectorWrapper(DataProvider provider, DetectionConfigDTO 
config, long startTime, long endTime) {
     super(provider, config, startTime, endTime);
 
+    
Preconditions.checkArgument(this.config.getProperties().containsKey(PROP_SUB_ENTITY_NAME));
+    this.entityName = MapUtils.getString(config.getProperties(), 
PROP_SUB_ENTITY_NAME);
+
     this.metricUrn = MapUtils.getString(config.getProperties(), 
PROP_METRIC_URN);
     this.metricEntity = MetricEntity.fromURN(this.metricUrn);
     this.metric = 
provider.fetchMetrics(Collections.singleton(this.metricEntity.getId())).get(this.metricEntity.getId());
@@ -208,6 +213,7 @@ public class AnomalyDetectorWrapper extends 
DetectionPipeline {
       anomaly.setCollection(this.metric.getDataset());
       
anomaly.setDimensions(DetectionUtils.toFilterMap(this.metricEntity.getFilters()));
       anomaly.getProperties().put(PROP_DETECTOR_COMPONENT_NAME, 
this.detectorName);
+      anomaly.getProperties().put(PROP_SUB_ENTITY_NAME, this.entityName);
     }
     long lastTimeStamp = this.getLastTimeStamp();
     List<MergedAnomalyResultDTO> anomalyResults = 
anomalies.stream().filter(anomaly -> anomaly.getEndTime() <= 
lastTimeStamp).collect(
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/GrouperWrapper.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/GrouperWrapper.java
index cfffd14..0aad39f 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/GrouperWrapper.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/wrapper/GrouperWrapper.java
@@ -38,17 +38,20 @@ import org.apache.pinot.thirdeye.detection.DetectionUtils;
 import org.apache.pinot.thirdeye.detection.PredictionResult;
 import org.apache.pinot.thirdeye.detection.spi.components.Grouper;
 
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
+
 
 /**
  * A group wrapper which triggers the configured grouper. The actual grouper
  * must implement the {@link Grouper} interface.
+ *
+ * A grouper must always return grouped (parent) anomalies - no child anomalies
  */
 public class GrouperWrapper extends DetectionPipeline {
   private static final String PROP_NESTED = "nested";
   private static final String PROP_CLASS_NAME = "className";
   private static final String PROP_GROUPER = "grouper";
   private static final String PROP_DETECTOR_COMPONENT_NAME = 
"detectorComponentName";
-  private static final String PROP_ENTITY_NAME = "entityName";
 
   private final List<Map<String, Object>> nestedProperties;
 
@@ -68,8 +71,8 @@ public class GrouperWrapper extends DetectionPipeline {
     
Preconditions.checkArgument(this.config.getComponents().containsKey(this.grouperName));
     this.grouper = (Grouper) this.config.getComponents().get(this.grouperName);
 
-    
Preconditions.checkArgument(this.config.getProperties().containsKey(PROP_ENTITY_NAME));
-    this.entityName = 
this.config.getProperties().get(PROP_ENTITY_NAME).toString();
+    
Preconditions.checkArgument(this.config.getProperties().containsKey(PROP_SUB_ENTITY_NAME));
+    this.entityName = MapUtils.getString(config.getProperties(), 
PROP_SUB_ENTITY_NAME);
   }
 
   /**
@@ -114,8 +117,11 @@ public class GrouperWrapper extends DetectionPipeline {
       }
 
       anomaly.setDetectionConfigId(this.config.getId());
+      if (anomaly.getProperties() == null) {
+        anomaly.setProperties(new HashMap<>());
+      }
       anomaly.getProperties().put(PROP_DETECTOR_COMPONENT_NAME, 
this.grouperName);
-      anomaly.getProperties().put(PROP_ENTITY_NAME, this.entityName);
+      anomaly.getProperties().put(PROP_SUB_ENTITY_NAME, this.entityName);
     }
 
     return new DetectionPipelineResult(anomalies, 
DetectionUtils.consolidateNestedLastTimeStamps(lastTimeStamps),
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
index 68a7e54..cca68d1 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/translator/DetectionConfigTranslator.java
@@ -123,6 +123,8 @@ import static 
org.apache.pinot.thirdeye.detection.yaml.DetectionConfigTuner.*;
  *
  */
 public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigDTO, DetectionConfigValidator> {
+  public static final String PROP_SUB_ENTITY_NAME = "subEntityName";
+
   private static final String PROP_DIMENSION_EXPLORATION = 
"dimensionExploration";
   private static final String PROP_DETECTION = "detection";
   private static final String PROP_CRON = "cron";
@@ -130,7 +132,6 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
   private static final String PROP_FILTERS = "filters";
   private static final String PROP_TYPE = "type";
   private static final String PROP_CLASS_NAME = "className";
-  private static final String PROP_ENTITY_NAME = "entityName";
   private static final String PROP_PARAMS = "params";
   private static final String PROP_METRIC_URN = "metricUrn";
   private static final String PROP_DIMENSION_FILTER_METRIC = 
"dimensionFilterMetric";
@@ -188,6 +189,8 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
   }
 
   private Map<String, Object> translateMetricAlert(Map<String, Object> 
metricAlertConfigMap) {
+    String subEntityName = MapUtils.getString(metricAlertConfigMap, PROP_NAME);
+
     DatasetConfigDTO datasetConfigDTO = 
metricAttributesMap.fetchDataset(metricAlertConfigMap);
     Map<String, Collection<String>> dimensionFiltersMap = 
ConfigUtils.getMap(metricAlertConfigMap.get(PROP_FILTERS));
     String metricUrn = MetricEntity.fromMetric(dimensionFiltersMap, 
metricAttributesMap.fetchMetric(metricAlertConfigMap).getId()).getUrn();
@@ -199,7 +202,8 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
     for (Map<String, Object> ruleYaml : ruleYamls) {
       List<Map<String, Object>> filterYamls = 
ConfigUtils.getList(ruleYaml.get(PROP_FILTER));
       List<Map<String, Object>> detectionYamls = 
ConfigUtils.getList(ruleYaml.get(PROP_DETECTION));
-      List<Map<String, Object>> detectionProperties = 
buildListOfMergeWrapperProperties(metricUrn, detectionYamls, mergerProperties,
+      List<Map<String, Object>> detectionProperties = 
buildListOfMergeWrapperProperties(
+          subEntityName, metricUrn, detectionYamls, mergerProperties,
           datasetConfigDTO.bucketTimeGranularity());
       if (filterYamls.isEmpty()) {
         nestedPipelines.addAll(detectionProperties);
@@ -223,7 +227,6 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
 
     // Wrap with metric level grouper, restricting to only 1 grouper
     List<Map<String, Object>> grouperYamls = 
getList(metricAlertConfigMap.get(PROP_GROUPER));
-    String subEntityName = MapUtils.getString(metricAlertConfigMap, PROP_NAME);
     if (!grouperYamls.isEmpty()) {
       properties = buildWrapperProperties(
           ChildKeepingMergeWrapper.class.getName(),
@@ -236,6 +239,7 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
 
   private Map<String, Object> translateCompositeAlert(Map<String, Object> 
compositeAlertConfigMap) {
     Map<String, Object> properties;
+    String subEntityName = MapUtils.getString(compositeAlertConfigMap, 
PROP_NAME);
 
     // Recursively translate all the sub-alerts
     List<Map<String, Object>> subDetectionYamls = 
ConfigUtils.getList(compositeAlertConfigMap.get(PROP_ALERTS));
@@ -253,7 +257,6 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
 
     // Wrap the entity level grouper, only 1 grouper is supported now
     List<Map<String, Object>> grouperProps = 
ConfigUtils.getList(compositeAlertConfigMap.get(PROP_GROUPER));
-    String subEntityName = MapUtils.getString(compositeAlertConfigMap, 
PROP_NAME);
     if (!grouperProps.isEmpty()) {
       properties = buildGroupWrapperProperties(subEntityName, 
grouperProps.get(0), nestedPropertiesList);
       nestedPropertiesList = Collections.singletonList(properties);
@@ -318,21 +321,22 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
     return dimensionWrapperProperties;
   }
 
-  private List<Map<String, Object>> buildListOfMergeWrapperProperties(String 
metricUrn, List<Map<String, Object>> yamlConfigs,
-      Map<String, Object> mergerProperties, TimeGranularity 
datasetTimegranularity) {
+  private List<Map<String, Object>> buildListOfMergeWrapperProperties(String 
subEntityName, String metricUrn,
+      List<Map<String, Object>> yamlConfigs, Map<String, Object> 
mergerProperties, TimeGranularity datasetTimegranularity) {
     List<Map<String, Object>> properties = new ArrayList<>();
     for (Map<String, Object> yamlConfig : yamlConfigs) {
-      properties.add(buildMergeWrapperProperties(metricUrn, yamlConfig, 
mergerProperties, datasetTimegranularity));
+      properties.add(buildMergeWrapperProperties(subEntityName, metricUrn, 
yamlConfig, mergerProperties, datasetTimegranularity));
     }
     return properties;
   }
 
-  private Map<String, Object> buildMergeWrapperProperties(String metricUrn, 
Map<String, Object> yamlConfig,
+  private Map<String, Object> buildMergeWrapperProperties(String 
subEntityName, String metricUrn, Map<String, Object> yamlConfig,
       Map<String, Object> mergerProperties, TimeGranularity 
datasetTimegranularity) {
     String detectorType = MapUtils.getString(yamlConfig, PROP_TYPE);
     String name = MapUtils.getString(yamlConfig, PROP_NAME);
     Map<String, Object> nestedProperties = new HashMap<>();
     nestedProperties.put(PROP_CLASS_NAME, 
AnomalyDetectorWrapper.class.getName());
+    nestedProperties.put(PROP_SUB_ENTITY_NAME, subEntityName);
     String detectorRefKey = makeComponentRefKey(detectorType, name);
 
     fillInDetectorWrapperProperties(nestedProperties, yamlConfig, 
detectorType, datasetTimegranularity);
@@ -367,9 +371,7 @@ public class DetectionConfigTranslator extends 
ConfigTranslator<DetectionConfigD
     Map<String, Object> properties = new HashMap<>();
     properties.put(PROP_CLASS_NAME, GrouperWrapper.class.getName());
     properties.put(PROP_NESTED, nestedProps);
-    if (entityName != null) {
-      properties.put(PROP_ENTITY_NAME, entityName);
-    }
+    properties.put(PROP_SUB_ENTITY_NAME, entityName);
 
     String grouperType = MapUtils.getString(grouperYaml, PROP_TYPE);
     String grouperName = MapUtils.getString(grouperYaml, PROP_NAME);
diff --git 
a/thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/entity-groupby-anomaly-report.ftl
 
b/thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/entity-groupkey-anomaly-report.ftl
similarity index 100%
rename from 
thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/entity-groupby-anomaly-report.ftl
rename to 
thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/entity-groupkey-anomaly-report.ftl
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/alert/content/TestEntityGroupByEmailContentFormatter.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/alert/content/TestEntityGroupKeyEmailContentFormatter.java
similarity index 95%
rename from 
thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/alert/content/TestEntityGroupByEmailContentFormatter.java
rename to 
thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/alert/content/TestEntityGroupKeyEmailContentFormatter.java
index 8ce134d..8035dd4 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/alert/content/TestEntityGroupByEmailContentFormatter.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/alert/content/TestEntityGroupKeyEmailContentFormatter.java
@@ -49,11 +49,12 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import static 
org.apache.pinot.thirdeye.alert.content.EntityGroupByContentFormatter.*;
+import static 
org.apache.pinot.thirdeye.alert.content.EntityGroupKeyContentFormatter.*;
 import static org.apache.pinot.thirdeye.anomaly.SmtpConfiguration.*;
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
 
 
-public class TestEntityGroupByEmailContentFormatter {
+public class TestEntityGroupKeyEmailContentFormatter {
   private static final String TEST = "test";
   private int id = 0;
   private String dashboardHost = "http://localhost:8080/dashboard";;
@@ -121,7 +122,7 @@ public class TestEntityGroupByEmailContentFormatter {
         id);
     Map<String, String> properties = new HashMap<>();
     properties.put(PROP_GROUP_KEY, "group-1");
-    properties.put(PROP_ENTITY_NAME, "sub-entity-A");
+    properties.put(PROP_SUB_ENTITY_NAME, "sub-entity-A");
     properties.put(PROP_ANOMALY_SCORE, "10");
     subGroupedAnomaly1.setProperties(properties);
     subGroupedAnomaly1.setChildIds(Collections.singleton(1l));
@@ -134,7 +135,7 @@ public class TestEntityGroupByEmailContentFormatter {
         id);
     Map<String, String> properties2 = new HashMap<>();
     properties2.put(PROP_GROUP_KEY, "group-2");
-    properties2.put(PROP_ENTITY_NAME, "sub-entity-B");
+    properties2.put(PROP_SUB_ENTITY_NAME, "sub-entity-B");
     properties2.put(PROP_ANOMALY_SCORE, "20");
     subGroupedAnomaly2.setProperties(properties2);
     subGroupedAnomaly2.setChildIds(Collections.singleton(2l));
@@ -153,7 +154,7 @@ public class TestEntityGroupByEmailContentFormatter {
     List<AnomalyResult> anomalies = new ArrayList<>();
     anomalies.add(parentGroupedAnomaly);
 
-    EmailContentFormatter contentFormatter = new 
EntityGroupByContentFormatter();
+    EmailContentFormatter contentFormatter = new 
EntityGroupKeyContentFormatter();
     contentFormatter.init(new Properties(), 
EmailContentFormatterConfiguration.fromThirdEyeAnomalyConfiguration(thirdeyeAnomalyConfig));
     EmailEntity emailEntity = contentFormatter.getEmailEntity(
         DaoTestUtils.getTestAlertConfiguration("Test Config"),
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouperTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouperTest.java
index 0df68bd..3e2ab9d 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouperTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/components/TriggerConditionGrouperTest.java
@@ -31,6 +31,7 @@ import org.testng.annotations.Test;
 
 import static org.apache.pinot.thirdeye.detection.DetectionUtils.*;
 import static 
org.apache.pinot.thirdeye.detection.components.TriggerConditionGrouper.*;
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
 
 
 public class TriggerConditionGrouperTest {
@@ -40,7 +41,7 @@ public class TriggerConditionGrouperTest {
   public static MergedAnomalyResultDTO makeAnomaly(long start, long end, 
String entity) {
     MergedAnomalyResultDTO anomaly = DetectionTestUtils.makeAnomaly(1000l, 
start, end, null, null, Collections.<String, String>emptyMap());
     Map<String, String> props = new HashMap<>();
-    props.put(PROP_ENTITY_NAME, entity);
+    props.put(PROP_SUB_ENTITY_NAME, entity);
     anomaly.setProperties(props);
     return anomaly;
   }
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapperTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapperTest.java
index 1671224..c980e96 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapperTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/wrapper/AnomalyDetectorWrapperTest.java
@@ -18,8 +18,6 @@ package org.apache.pinot.thirdeye.detection.wrapper;
 
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ListMultimap;
-import java.sql.Time;
 import org.apache.pinot.thirdeye.common.time.TimeGranularity;
 import org.apache.pinot.thirdeye.common.time.TimeSpec;
 import org.apache.pinot.thirdeye.dataframe.DataFrame;
@@ -45,6 +43,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import static org.apache.pinot.thirdeye.dataframe.util.DataFrameUtils.*;
+import static 
org.apache.pinot.thirdeye.detection.yaml.translator.DetectionConfigTranslator.*;
 
 
 public class AnomalyDetectorWrapperTest {
@@ -62,6 +61,7 @@ public class AnomalyDetectorWrapperTest {
     this.properties = new HashMap<>();
     this.properties.put(PROP_METRIC_URN, "thirdeye:metric:1");
     this.properties.put(PROP_DETECTOR, "$testDetector");
+    this.properties.put(PROP_SUB_ENTITY_NAME, "test_detector");
     this.config = new DetectionConfigDTO();
     this.config.setComponents(ImmutableMap.of("testDetector", new 
ThresholdRuleDetector()));
     this.config.setProperties(properties);
diff --git 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-1.json
 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-1.json
index 6aa2bbf..524553f 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-1.json
+++ 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-1.json
@@ -5,7 +5,7 @@
     "nested": [
       {
         "grouper": "$test_grouper:MOCK_GROUPER",
-        "entityName": "testPipeline",
+        "subEntityName": "testPipeline",
         "className": 
"org.apache.pinot.thirdeye.detection.wrapper.GrouperWrapper",
         "nested": [
           {
@@ -34,6 +34,7 @@
                             "nested": [
                               {
                                 "bucketPeriod": "P1D",
+                                "subEntityName": "testPipeline",
                                 "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
                               }
                             ],
@@ -55,6 +56,7 @@
                         "nested": [
                           {
                             "bucketPeriod": "P1D",
+                            "subEntityName": "testPipeline",
                             "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
                           }
                         ],
diff --git 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-2.json
 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-2.json
index 06a93fd..a220aa6 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-2.json
+++ 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-2.json
@@ -10,6 +10,7 @@
         "className": 
"org.apache.pinot.thirdeye.detection.wrapper.BaselineFillingMergeWrapper",
         "nested": [{
           "bucketPeriod": "P1D",
+          "subEntityName": "testPipeline",
           "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
         }],
         "detector": "$rule1:THRESHOLD"
diff --git 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-4.json
 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-4.json
index 9885a70..de89f23 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-4.json
+++ 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-4.json
@@ -12,6 +12,7 @@
           "className": 
"org.apache.pinot.thirdeye.detection.wrapper.BaselineFillingMergeWrapper",
           "nested": [{
             "bucketPeriod": "P1D",
+            "subEntityName": "metric alert on test_metric",
             "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
           }],
           "detector": "$maxThreshold_1:THRESHOLD"
diff --git 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-5.json
 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-5.json
index 3ecc10e..50391e4 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-5.json
+++ 
b/thirdeye/thirdeye-pinot/src/test/resources/org/apache/pinot/thirdeye/detection/yaml/translator/compositePipelineTranslatorTestResult-5.json
@@ -18,6 +18,7 @@
               "className": 
"org.apache.pinot.thirdeye.detection.wrapper.BaselineFillingMergeWrapper",
               "nested": [{
                 "bucketPeriod": "P1D",
+                "subEntityName" : "metric_alert_on_test_metric",
                 "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
               }],
               "detector": "$maxThreshold_1:THRESHOLD"
@@ -29,6 +30,7 @@
             "className": 
"org.apache.pinot.thirdeye.detection.wrapper.BaselineFillingMergeWrapper",
             "nested": [{
               "bucketPeriod": "P1D",
+              "subEntityName" : "metric_alert_on_test_metric",
               "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
             }],
             "detector": "$maxThreshold_2:THRESHOLD"
@@ -49,6 +51,7 @@
             "className": 
"org.apache.pinot.thirdeye.detection.wrapper.BaselineFillingMergeWrapper",
             "nested": [{
               "bucketPeriod": "P1D",
+              "subEntityName" : "metric_alert_on_test_metric",
               "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
             }],
             "detector": "$maxThreshold_1:THRESHOLD"
@@ -65,6 +68,7 @@
               "className": 
"org.apache.pinot.thirdeye.detection.wrapper.BaselineFillingMergeWrapper",
               "nested": [{
                 "bucketPeriod": "P1D",
+                "subEntityName" : "another_metric_alert_on_test_metric",
                 "className": 
"org.apache.pinot.thirdeye.detection.wrapper.AnomalyDetectorWrapper"
               }],
               "detector": "$maxThreshold_1:THRESHOLD"


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to