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 7b4a4e7  [TE][notification] Support configuring reference links per 
dimensional recipients (#4893)
7b4a4e7 is described below

commit 7b4a4e7ff28a39a96c6b2ddc7183692f60b57377
Author: Akshay Rai <[email protected]>
AuthorDate: Fri Dec 6 08:45:54 2019 -0800

    [TE][notification] Support configuring reference links per dimensional 
recipients (#4893)
    
    This PR enables configuration of referenceLinks and potential other 
subscription related settings in the DIMENSIONS_ALERTER_PIPELINE. For example, 
this can enable users to configure different oncall-runbooks per anomalous 
dimension.
---
 .../alert/DetectionAlertFilterNotification.java    | 23 ++++----
 .../alert/StatefulDetectionAlertFilter.java        |  4 +-
 .../filter/DimensionDetectionAlertFilter.java      | 14 ++---
 .../filter/DimensionsRecipientAlertFilter.java     | 15 +++---
 .../alert/filter/PerUserDimensionAlertFilter.java  | 14 ++---
 .../detection/alert/filter/SubscriptionUtils.java  | 58 ++++++++++++++++++++
 .../ToAllRecipientsDetectionAlertFilter.java       | 15 +++---
 .../alert/scheme/DetectionEmailAlerter.java        | 17 +++---
 .../alert/scheme/DetectionJiraAlerter.java         | 10 ++--
 .../detection/alert/filter/AlertFilterUtils.java   | 19 +++++--
 ...ava => DimensionsRecipientAlertFilterTest.java} | 61 +++++++++++++++-------
 .../alert/scheme/DetectionEmailAlerterTest.java    | 12 +++--
 .../alert/scheme/DetectionJiraAlerterTest.java     | 12 +++--
 .../DetectionTimeWindowSuppressorTest.java         | 20 ++++---
 .../tools/RunAdhocDatabaseQueriesTool.java         | 14 +++--
 15 files changed, 216 insertions(+), 92 deletions(-)

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertFilterNotification.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertFilterNotification.java
index b5ba6f9..bbb3f88 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertFilterNotification.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/DetectionAlertFilterNotification.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Multimap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
+import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 
 
 /**
@@ -31,24 +32,24 @@ import java.util.Objects;
  */
 public class DetectionAlertFilterNotification {
 
-  Map<String, Object> notificationSchemeProps;
+  DetectionAlertConfigDTO subsConfig;
   Multimap<String, String> dimensionFilters;
 
-  public DetectionAlertFilterNotification(Map<String, Object> 
notificationSchemeProps) {
-    this(notificationSchemeProps, ArrayListMultimap.create());
+  public DetectionAlertFilterNotification(DetectionAlertConfigDTO subsConfig) {
+    this(subsConfig, ArrayListMultimap.create());
   }
 
-  public DetectionAlertFilterNotification(Map<String, Object> 
notificationSchemeProps, Multimap<String, String> dimensionFilters) {
-    this.notificationSchemeProps = notificationSchemeProps;
+  public DetectionAlertFilterNotification(DetectionAlertConfigDTO subsConfig, 
Multimap<String, String> dimensionFilters) {
+    this.subsConfig = subsConfig;
     this.dimensionFilters = dimensionFilters;
   }
 
-  public Map<String, Object> getNotificationSchemeProps() {
-    return notificationSchemeProps;
+  public DetectionAlertConfigDTO getSubscriptionConfig() {
+    return subsConfig;
   }
 
-  public void setNotificationSchemeProps(Map<String, Object> 
notificationSchemeProps) {
-    this.notificationSchemeProps = notificationSchemeProps;
+  public void setSubscriptionConfig(DetectionAlertConfigDTO subsConfig) {
+    this.subsConfig = subsConfig;
   }
 
   public Multimap<String, String> getDimensionFilters() {
@@ -68,13 +69,13 @@ public class DetectionAlertFilterNotification {
       return false;
     }
     DetectionAlertFilterNotification that = (DetectionAlertFilterNotification) 
o;
-    return Objects.equals(notificationSchemeProps, 
that.notificationSchemeProps) &&
+    return Objects.equals(subsConfig, that.subsConfig) &&
         Objects.equals(dimensionFilters, that.dimensionFilters);
   }
 
   @Override
   public int hashCode() {
-    return Objects.hash(notificationSchemeProps, dimensionFilters);
+    return Objects.hash(subsConfig, dimensionFilters);
   }
 
 }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
index 3a15235..41b3df4 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/StatefulDetectionAlertFilter.java
@@ -114,9 +114,9 @@ public abstract class StatefulDetectionAlertFilter extends 
DetectionAlertFilter
     return filteredRecipients;
   }
 
-  protected Map<String, Object> 
generateNotificationSchemeProps(DetectionAlertConfigDTO config,
+  protected Map<String, Map<String, Object>> 
generateNotificationSchemeProps(DetectionAlertConfigDTO config,
       Set<String> to, Set<String> cc, Set<String> bcc) {
-    Map<String, Object> notificationSchemeProps = new HashMap<>();
+    Map<String, Map<String, Object>> notificationSchemeProps = new HashMap<>();
 
     if (config.getAlertSchemes() == null) {
       Map<String, Map<String, Object>> alertSchemes = new HashMap<>();
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionDetectionAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionDetectionAlertFilter.java
index 14b3746..1a36588 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionDetectionAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionDetectionAlertFilter.java
@@ -86,13 +86,15 @@ public class DimensionDetectionAlertFilter extends 
StatefulDetectionAlertFilter
     });
 
     for (Map.Entry<String, Collection<MergedAnomalyResultDTO>> 
dimAnomalyMapping : grouped.asMap().entrySet()) {
+      DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(
+          generateNotificationSchemeProps(
+              this.config,
+              this.makeGroupRecipients(dimAnomalyMapping.getKey()),
+              this.recipients.get(PROP_CC),
+              this.recipients.get(PROP_BCC)));
+
       result.addMapping(
-          new DetectionAlertFilterNotification(
-              generateNotificationSchemeProps(
-                  this.config,
-                  this.makeGroupRecipients(dimAnomalyMapping.getKey()),
-                  this.recipients.get(PROP_CC),
-                  this.recipients.get(PROP_BCC))),
+          new DetectionAlertFilterNotification(subsConfig),
           new HashSet<>(dimAnomalyMapping.getValue()));
     }
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
index 7acbc63..4f7c70d 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilter.java
@@ -20,7 +20,6 @@
 package org.apache.pinot.thirdeye.detection.alert.filter;
 
 import com.google.common.collect.Multimap;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -42,6 +41,9 @@ import org.apache.pinot.thirdeye.rootcause.impl.MetricEntity;
  * to a set of unconditional and another set of conditional recipients, based 
on the
  * value of a specified anomaly dimension combinations.
  *
+ * Unlike {@link DimensionDetectionAlertFilter}, here you can configure 
multiple dimension
+ * combinations along with a variety of alerting channels and reference links.
+ *
  * <pre>
  * dimensionRecipients:
  *   - dimensions:
@@ -69,19 +71,16 @@ public class DimensionsRecipientAlertFilter extends 
StatefulDetectionAlertFilter
   public static final String PROP_DETECTION_CONFIG_IDS = "detectionConfigIds";
   public static final String PROP_DIMENSION = "dimensions";
   public static final String PROP_NOTIFY = "notify";
+  public static final String PROP_REF_LINKS = "referenceLinks";
   public static final String PROP_DIMENSION_RECIPIENTS = "dimensionRecipients";
   private static final String PROP_SEND_ONCE = "sendOnce";
 
-  private Map<String, Object> defaultNotificationSchemeProps = new HashMap<>();
   final List<Map<String, Object>> dimensionRecipients;
   final List<Long> detectionConfigIds;
   final boolean sendOnce;
 
   public DimensionsRecipientAlertFilter(DataProvider provider, 
DetectionAlertConfigDTO config, long endTime) {
     super(provider, config, endTime);
-    for (Map.Entry<String, Map<String, Object>> schemeProps : 
this.config.getAlertSchemes().entrySet()) {
-      defaultNotificationSchemeProps.put(schemeProps.getKey(), new 
HashMap<>(schemeProps.getValue()));
-    }
     this.dimensionRecipients = 
ConfigUtils.getList(this.config.getProperties().get(PROP_DIMENSION_RECIPIENTS));
     this.detectionConfigIds = 
ConfigUtils.getLongs(this.config.getProperties().get(PROP_DETECTION_CONFIG_IDS));
     this.sendOnce = MapUtils.getBoolean(this.config.getProperties(), 
PROP_SEND_ONCE, true);
@@ -106,8 +105,10 @@ public class DimensionsRecipientAlertFilter extends 
StatefulDetectionAlertFilter
       }
 
       if (!notifyAnomalies.isEmpty()) {
+        DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(config,
+            ConfigUtils.getMap(dimensionRecipient.get(PROP_NOTIFY)), 
ConfigUtils.getMap(dimensionRecipient.get(PROP_REF_LINKS)));
         result.addMapping(
-            new 
DetectionAlertFilterNotification(ConfigUtils.getMap(dimensionRecipient.get(PROP_NOTIFY)),
 dimensionFilters),
+            new DetectionAlertFilterNotification(subsConfig, dimensionFilters),
             notifyAnomalies);
       }
     }
@@ -121,7 +122,7 @@ public class DimensionsRecipientAlertFilter extends 
StatefulDetectionAlertFilter
       }
     }
     if (!defaultAnomalies.isEmpty()) {
-      result.addMapping(new 
DetectionAlertFilterNotification(defaultNotificationSchemeProps), 
defaultAnomalies);
+      result.addMapping(new DetectionAlertFilterNotification(config), 
defaultAnomalies);
     }
 
     return result;
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilter.java
index 86b9048..7d1906c 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/PerUserDimensionAlertFilter.java
@@ -106,13 +106,15 @@ public class PerUserDimensionAlertFilter extends 
StatefulDetectionAlertFilter {
     }
 
     for (Map.Entry<String, List<MergedAnomalyResultDTO>> userAnomalyMapping : 
perUserAnomalies.entrySet()) {
+      DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(
+          generateNotificationSchemeProps(
+              this.config,
+              this.makeGroupRecipients(userAnomalyMapping.getKey()),
+              this.recipients.get(PROP_CC),
+              this.recipients.get(PROP_BCC)));
+
       result.addMapping(
-          new DetectionAlertFilterNotification(
-              generateNotificationSchemeProps(
-                  this.config,
-                  this.makeGroupRecipients(userAnomalyMapping.getKey()),
-                  this.recipients.get(PROP_CC),
-                  this.recipients.get(PROP_BCC))),
+          new DetectionAlertFilterNotification(subsConfig),
           new HashSet<>(userAnomalyMapping.getValue()));
     }
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
new file mode 100644
index 0000000..f513e89
--- /dev/null
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/SubscriptionUtils.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.thirdeye.detection.alert.filter;
+
+import java.util.Map;
+import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+
+
+public class SubscriptionUtils {
+
+  public static DetectionAlertConfigDTO 
makeChildSubscriptionConfig(Map<String, Map<String, Object>> alertSchemes) {
+    return SubscriptionUtils.makeChildSubscriptionConfig(new 
DetectionAlertConfigDTO(), alertSchemes, null);
+  }
+
+  /**
+   * Make a new(child) subscription group from given(parent) subscription 
group.
+   *
+   * This is used   preparing the notification for each dimensional recipients.
+   */
+  public static DetectionAlertConfigDTO makeChildSubscriptionConfig(
+      DetectionAlertConfigDTO parentConfig,
+      Map<String, Map<String, Object>> alertSchemes,
+      Map<String, String> refLinks) {
+    DetectionAlertConfigDTO subsConfig = new DetectionAlertConfigDTO();
+    subsConfig.setId(parentConfig.getId());
+    subsConfig.setFrom(parentConfig.getFrom());
+    subsConfig.setActive(parentConfig.isActive());
+    subsConfig.setOwners(parentConfig.getOwners());
+    subsConfig.setYaml(parentConfig.getYaml());
+    subsConfig.setApplication(parentConfig.getApplication());
+    subsConfig.setName(parentConfig.getName());
+    subsConfig.setSubjectType(parentConfig.getSubjectType());
+    subsConfig.setProperties(parentConfig.getProperties());
+    subsConfig.setVectorClocks(parentConfig.getVectorClocks());
+
+    subsConfig.setAlertSchemes(alertSchemes);
+    subsConfig.setReferenceLinks(refLinks);
+
+    return subsConfig;
+  }
+}
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilter.java
index 9d01f96..d49e448 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/filter/ToAllRecipientsDetectionAlertFilter.java
@@ -69,13 +69,16 @@ public class ToAllRecipientsDetectionAlertFilter extends 
StatefulDetectionAlertF
     // Fetch all the anomalies to be notified to the recipients
     Set<MergedAnomalyResultDTO> anomalies = 
this.filter(this.makeVectorClocks(this.detectionConfigIds), minId);
 
+    DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(
+        generateNotificationSchemeProps(
+            this.config,
+            this.recipients.get(PROP_TO),
+            this.recipients.get(PROP_CC),
+            this.recipients.get(PROP_BCC))
+    );
+
     return result.addMapping(
-        new DetectionAlertFilterNotification(
-            generateNotificationSchemeProps(
-                this.config,
-                this.recipients.get(PROP_TO),
-                this.recipients.get(PROP_CC),
-                this.recipients.get(PROP_BCC))),
+        new DetectionAlertFilterNotification(subsConfig),
         anomalies);
   }
 
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 a8b7f2c..ffb1e45 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
@@ -137,14 +137,15 @@ public class DetectionEmailAlerter extends 
DetectionAlertScheme {
     }
   }
 
-  private HtmlEmail prepareEmailContent(Properties emailClientConfigs, 
List<AnomalyResult> anomalies, DetectionAlertFilterRecipients recipients) 
throws Exception {
+  private HtmlEmail prepareEmailContent(DetectionAlertConfigDTO subsConfig, 
Properties emailClientConfigs,
+      List<AnomalyResult> anomalies, DetectionAlertFilterRecipients 
recipients) throws Exception {
     configureAdminRecipients(recipients);
     whitelistRecipients(recipients);
     blacklistRecipients(recipients);
     validateAlert(recipients, anomalies);
 
     BaseNotificationContent content = 
buildNotificationContent(emailClientConfigs);
-    EmailEntity emailEntity = new EmailContentFormatter(emailClientConfigs, 
content, this.teConfig, this.subsConfig)
+    EmailEntity emailEntity = new EmailContentFormatter(emailClientConfigs, 
content, this.teConfig, subsConfig)
         .getEmailEntity(anomalies);
     if (Strings.isNullOrEmpty(this.subsConfig.getFrom())) {
       throw new IllegalArgumentException("Invalid sender's email");
@@ -189,17 +190,17 @@ public class DetectionEmailAlerter extends 
DetectionAlertScheme {
     Preconditions.checkNotNull(results.getResult());
     for (Map.Entry<DetectionAlertFilterNotification, 
Set<MergedAnomalyResultDTO>> result : results.getResult().entrySet()) {
       try {
-        Map<String, Object> notificationSchemeProps = 
result.getKey().getNotificationSchemeProps();
-        if (notificationSchemeProps == null || 
notificationSchemeProps.get(PROP_EMAIL_SCHEME) == null) {
+        DetectionAlertConfigDTO subsConfig = 
result.getKey().getSubscriptionConfig();
+        if (subsConfig.getAlertSchemes().get(PROP_EMAIL_SCHEME) == null) {
           throw new IllegalArgumentException("Invalid email settings in 
subscription group " + this.subsConfig.getId());
         }
 
-        Properties emailClientConfigs = new Properties();
-        
emailClientConfigs.putAll(ConfigUtils.getMap(notificationSchemeProps.get(PROP_EMAIL_SCHEME)));
-
         List<AnomalyResult> anomalyResultListOfGroup = new 
ArrayList<>(result.getValue());
         anomalyResultListOfGroup.sort(COMPARATOR_DESC);
 
+        Properties emailClientConfigs = new Properties();
+        
emailClientConfigs.putAll(subsConfig.getAlertSchemes().get(PROP_EMAIL_SCHEME));
+
         if (emailClientConfigs.get(PROP_RECIPIENTS) != null) {
           Map<String, Object> emailRecipients = 
ConfigUtils.getMap(emailClientConfigs.get(PROP_RECIPIENTS));
           if (emailRecipients.get(PROP_TO) == null || 
ConfigUtils.getList(emailRecipients.get(PROP_TO)).isEmpty()) {
@@ -210,7 +211,7 @@ public class DetectionEmailAlerter extends 
DetectionAlertScheme {
               new HashSet<>(ConfigUtils.getList(emailRecipients.get(PROP_TO))),
               new HashSet<>(ConfigUtils.getList(emailRecipients.get(PROP_CC))),
               new 
HashSet<>(ConfigUtils.getList(emailRecipients.get(PROP_BCC))));
-          sendEmail(prepareEmailContent(emailClientConfigs, 
anomalyResultListOfGroup, recipients));
+          sendEmail(prepareEmailContent(subsConfig, emailClientConfigs, 
anomalyResultListOfGroup, recipients));
         }
       } catch (IllegalArgumentException e) {
         super.handleAlertFailure(result.getValue().size(), e);
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
index e584caa..d561ac3 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerter.java
@@ -27,13 +27,11 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Properties;
 import java.util.Set;
-import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import org.apache.pinot.thirdeye.anomaly.ThirdEyeAnomalyConfiguration;
 import org.apache.pinot.thirdeye.anomalydetection.context.AnomalyResult;
 import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 import org.apache.pinot.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
-import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 import org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterResult;
 import org.apache.pinot.thirdeye.detection.annotation.AlertScheme;
@@ -120,20 +118,20 @@ public class DetectionJiraAlerter extends 
DetectionAlertScheme {
   }
 
   private JiraEntity buildJiraEntity(DetectionAlertFilterNotification 
notification, Set<MergedAnomalyResultDTO> anomalies) {
-    Map<String, Object> notificationSchemeProps = 
notification.getNotificationSchemeProps();
-    if (notificationSchemeProps == null || 
notificationSchemeProps.get(PROP_JIRA_SCHEME) == null) {
+    DetectionAlertConfigDTO subsetSubsConfig = 
notification.getSubscriptionConfig();
+    if (subsetSubsConfig.getAlertSchemes().get(PROP_JIRA_SCHEME) == null) {
       throw new IllegalArgumentException("Jira not configured in subscription 
group " + this.subsConfig.getId());
     }
 
     Properties jiraClientConfig = new Properties();
-    
jiraClientConfig.putAll(ConfigUtils.getMap(notificationSchemeProps.get(PROP_JIRA_SCHEME)));
+    
jiraClientConfig.putAll(subsetSubsConfig.getAlertSchemes().get(PROP_JIRA_SCHEME));
 
     List<AnomalyResult> anomalyResultListOfGroup = new ArrayList<>(anomalies);
     anomalyResultListOfGroup.sort(COMPARATOR_DESC);
 
     BaseNotificationContent content = 
super.buildNotificationContent(jiraClientConfig);
 
-    return new JiraContentFormatter(this.jiraAdminConfig, jiraClientConfig, 
content, this.teConfig, subsConfig)
+    return new JiraContentFormatter(this.jiraAdminConfig, jiraClientConfig, 
content, this.teConfig, subsetSubsConfig)
         .getJiraEntity(notification.getDimensionFilters(), 
anomalyResultListOfGroup);
   }
 
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
index 0d7f1b2..1282b94 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/AlertFilterUtils.java
@@ -21,6 +21,8 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 
 import static 
org.apache.pinot.thirdeye.detection.alert.scheme.DetectionEmailAlerter.*;
@@ -47,8 +49,9 @@ public class AlertFilterUtils {
     return makeEmailNotifications(recipients, PROP_CC_VALUE, PROP_BCC_VALUE);
   }
 
-  static DetectionAlertFilterNotification makeEmailNotifications(Set<String> 
toRecipients, Set<String> ccRecipients, Set<String> bccRecipients) {
-    Map<String, Object> alertProps = new HashMap<>();
+  static DetectionAlertFilterNotification 
makeEmailNotifications(DetectionAlertConfigDTO config,
+      Set<String> toRecipients, Set<String> ccRecipients, Set<String> 
bccRecipients) {
+    Map<String, Map<String, Object>> alertProps = new HashMap<>();
 
     Map<String, Set<String>> recipients = new HashMap<>();
     recipients.put(PROP_TO, new HashSet<>(toRecipients));
@@ -59,6 +62,16 @@ public class AlertFilterUtils {
     emailRecipients.put(PROP_RECIPIENTS, recipients);
 
     alertProps.put(PROP_EMAIL_SCHEME, emailRecipients);
-    return new DetectionAlertFilterNotification(alertProps);
+
+    DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(alertProps);
+    subsConfig.setProperties(config.getProperties());
+    subsConfig.setVectorClocks(config.getVectorClocks());
+    subsConfig.setReferenceLinks(config.getReferenceLinks());
+
+    return new DetectionAlertFilterNotification(subsConfig);
+  }
+
+  static DetectionAlertFilterNotification makeEmailNotifications(Set<String> 
toRecipients, Set<String> ccRecipients, Set<String> bccRecipients) {
+    return makeEmailNotifications(new DetectionAlertConfigDTO(), toRecipients, 
ccRecipients, bccRecipients);
   }
 }
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsDetectionAlertFilterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
similarity index 87%
rename from 
thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsDetectionAlertFilterTest.java
rename to 
thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
index 4afd27f..fa0d111 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsDetectionAlertFilterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/filter/DimensionsRecipientAlertFilterTest.java
@@ -51,7 +51,7 @@ import static 
org.apache.pinot.thirdeye.detection.DetectionTestUtils.*;
 import static 
org.apache.pinot.thirdeye.detection.alert.filter.DimensionsRecipientAlertFilter.*;
 
 
-public class DimensionsDetectionAlertFilterTest {
+public class DimensionsRecipientAlertFilterTest {
 
   private static final String PROP_RECIPIENTS = "recipients";
   private static final String PROP_TO = "to";
@@ -62,13 +62,11 @@ public class DimensionsDetectionAlertFilterTest {
   private static final Set<String> PROP_BCC_VALUE = new 
HashSet<>(Arrays.asList("[email protected]", "[email protected]"));
   private static final Set<String> PROP_TO_FOR_VALUE = new 
HashSet<>(Arrays.asList("[email protected]", "[email protected]"));
   private static final Set<String> PROP_TO_FOR_ANOTHER_VALUE = 
Collections.singleton("[email protected]");
-  //private static final List<Long> PROP_ID_VALUE = Arrays.asList(1001l, 
1002l);
   private static final List<Long> PROP_ID_VALUE = new ArrayList<>();
   private static final List<Map<String, Object>> 
PROP_DIMENSION_RECIPIENTS_VALUE = new ArrayList<>();
 
   private DetectionAlertFilter alertFilter;
   private List<MergedAnomalyResultDTO> detectedAnomalies;
-  private YamlResource yamlResource;
   private MockDataProvider provider;
   private DetectionAlertConfigDTO alertConfig;
   private DAOTestBase testDAOProvider;
@@ -78,7 +76,7 @@ public class DimensionsDetectionAlertFilterTest {
   private long detectionId3;
 
   @BeforeMethod
-  public void beforeMethod() throws IOException {
+  public void beforeMethod() {
     testDAOProvider = DAOTestBase.getInstance();
 
     
DetectionAlertRegistry.getInstance().registerAlertFilter("DIMENSIONS_ALERTER_PIPELINE",
@@ -119,6 +117,9 @@ public class DimensionsDetectionAlertFilterTest {
     notificationEmailParams1.put(PROP_RECIPIENTS, recipients1);
     notificationValues1.put("emailScheme", notificationEmailParams1);
     dimensionRecipient1.put(PROP_NOTIFY, notificationValues1);
+    Map<String, String> refLinks1 = new HashMap<>();
+    refLinks1.put("link1", "value1");
+    dimensionRecipient1.put(PROP_REF_LINKS, refLinks1);
 
     Map<String, Object> dimensionRecipient2 = new HashMap<>();
     Multimap<String, String> dimensionKeys2 = ArrayListMultimap.create();
@@ -134,6 +135,9 @@ public class DimensionsDetectionAlertFilterTest {
     notificationEmailParams2.put(PROP_RECIPIENTS, recipients2);
     notificationValues2.put("emailScheme", notificationEmailParams2);
     dimensionRecipient2.put(PROP_NOTIFY, notificationValues2);
+    Map<String, String> refLinks2 = new HashMap<>();
+    refLinks2.put("link2", "value2");
+    dimensionRecipient2.put(PROP_REF_LINKS, refLinks2);
 
     PROP_DIMENSION_RECIPIENTS_VALUE.add(dimensionRecipient1);
     PROP_DIMENSION_RECIPIENTS_VALUE.add(dimensionRecipient2);
@@ -181,6 +185,10 @@ public class DimensionsDetectionAlertFilterTest {
     vectorClocks.put(PROP_ID_VALUE.get(0), 0L);
     alertConfig.setVectorClocks(vectorClocks);
 
+    Map<String, String> refLinks = new HashMap<>();
+    refLinks.put("global_key", "global_value");
+    alertConfig.setReferenceLinks(refLinks);
+
     return alertConfig;
   }
 
@@ -192,25 +200,34 @@ public class DimensionsDetectionAlertFilterTest {
 
     // Send anomalies on un-configured dimensions to default recipients
     // Anomaly 0, 3 and 4 do not fall into any of the dimensionRecipients 
bucket. Send them to default recipients
-    DetectionAlertFilterNotification recDefault = 
AlertFilterUtils.makeEmailNotifications();
+    DetectionAlertFilterNotification recDefault = 
AlertFilterUtils.makeEmailNotifications(
+        this.alertConfig, PROP_TO_VALUE, PROP_CC_VALUE, PROP_BCC_VALUE);
     Assert.assertEquals(result.getResult().get(recDefault), makeSet(0, 3, 4));
 
+    // Send anomalies who dimensions are configured to appropriate recipients
+    DetectionAlertFilterNotification recValue = 
AlertFilterUtils.makeEmailNotifications(
+        this.alertConfig, PROP_TO_FOR_VALUE, PROP_CC_VALUE, PROP_BCC_VALUE);
     Multimap<String, String> dimFilters = ArrayListMultimap.create();
     dimFilters.put("key", "value");
-
-    // Send anomalies who dimensions are configured to appropriate recipients
-    DetectionAlertFilterNotification recValue = 
AlertFilterUtils.makeEmailNotifications(PROP_TO_FOR_VALUE, PROP_CC_VALUE, 
PROP_BCC_VALUE);
     recValue.setDimensionFilters(dimFilters);
+    Map<String, String> refLinks = new HashMap<>();
+    refLinks.put("link1", "value1");
+    recValue.getSubscriptionConfig().setReferenceLinks(refLinks);
+    Assert.assertTrue(result.getResult().containsKey(recValue));
     Assert.assertEquals(result.getResult().get(recValue), makeSet(1, 5));
 
+    // Send alert when configured dimensions is a subset of anomaly dimensions
+    // Anomaly 2 occurs on 3 dimensions (key 1, 2 & 3), dimensionRecipients is 
configured on (key 1 & 2) - send alert
+    DetectionAlertFilterNotification recAnotherValue = 
AlertFilterUtils.makeEmailNotifications(
+        this.alertConfig, PROP_TO_FOR_ANOTHER_VALUE, PROP_CC_VALUE, 
PROP_BCC_VALUE);
     dimFilters.removeAll("key");
     dimFilters.put("key1", "anotherValue1");
     dimFilters.put("key2", "anotherValue2");
-
-    // Send alert when configured dimensions is a subset of anomaly dimensions
-    // Anomaly 2 occurs on 3 dimensions (key 1, 2 & 3), dimensionRecipients is 
configured on (key 1 & 2) - send alert
-    DetectionAlertFilterNotification recAnotherValue = 
AlertFilterUtils.makeEmailNotifications(PROP_TO_FOR_ANOTHER_VALUE, 
PROP_CC_VALUE, PROP_BCC_VALUE);
     recAnotherValue.setDimensionFilters(dimFilters);
+    refLinks.clear();
+    refLinks.put("link2", "value2");
+    recAnotherValue.getSubscriptionConfig().setReferenceLinks(refLinks);
+    Assert.assertTrue(result.getResult().containsKey(recAnotherValue));
     Assert.assertEquals(result.getResult().get(recAnotherValue), makeSet(2));
   }
 
@@ -224,10 +241,14 @@ public class DimensionsDetectionAlertFilterTest {
 
     this.detectedAnomalies.add(child);
 
+    DetectionAlertFilterNotification recValue = 
AlertFilterUtils.makeEmailNotifications(
+        this.alertConfig, PROP_TO_FOR_VALUE, PROP_CC_VALUE, PROP_BCC_VALUE);
     Multimap<String, String> dimFilters = ArrayListMultimap.create();
     dimFilters.put("key", "value");
-    DetectionAlertFilterNotification recValue = 
AlertFilterUtils.makeEmailNotifications(PROP_TO_FOR_VALUE, PROP_CC_VALUE, 
PROP_BCC_VALUE);
     recValue.setDimensionFilters(dimFilters);
+    Map<String, String> refLinks = new HashMap<>();
+    refLinks.put("link1", "value1");
+    recValue.getSubscriptionConfig().setReferenceLinks(refLinks);
 
     DetectionAlertFilterResult result = this.alertFilter.run();
 
@@ -262,17 +283,21 @@ public class DimensionsDetectionAlertFilterTest {
     DetectionAlertFilterResult result = this.alertFilter.run();
     Assert.assertEquals(result.getResult().size(), 2);
 
-    Multimap<String, String> dimFilters = ArrayListMultimap.create();
-    dimFilters.put("key", "value");
-
-    DetectionAlertFilterNotification recDefault = 
AlertFilterUtils.makeEmailNotifications(PROP_TO_VALUE, PROP_CC_VALUE, 
PROP_BCC_VALUE);
+    DetectionAlertFilterNotification recDefault = 
AlertFilterUtils.makeEmailNotifications(
+        this.alertConfig, PROP_TO_VALUE, PROP_CC_VALUE, PROP_BCC_VALUE);
     Assert.assertTrue(result.getResult().containsKey(recDefault));
     Assert.assertEquals(result.getResult().get(recDefault).size(), 2);
     
Assert.assertTrue(result.getResult().get(recDefault).contains(anomalyWithoutFeedback));
     
Assert.assertTrue(result.getResult().get(recDefault).contains(anomalyWithNull));
 
-    DetectionAlertFilterNotification recValue = 
AlertFilterUtils.makeEmailNotifications(PROP_TO_FOR_VALUE, PROP_CC_VALUE, 
PROP_BCC_VALUE);
+    DetectionAlertFilterNotification recValue = 
AlertFilterUtils.makeEmailNotifications(
+        this.alertConfig, PROP_TO_FOR_VALUE, PROP_CC_VALUE, PROP_BCC_VALUE);
+    Multimap<String, String> dimFilters = ArrayListMultimap.create();
+    dimFilters.put("key", "value");
     recValue.setDimensionFilters(dimFilters);
+    Map<String, String> refLinks = new HashMap<>();
+    refLinks.put("link1", "value1");
+    recValue.getSubscriptionConfig().setReferenceLinks(refLinks);
     Assert.assertTrue(result.getResult().containsKey(recValue));
     Assert.assertEquals(result.getResult().get(recValue).size(), 1);
   }
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerterTest.java
index 04f83cb..f4a34ee 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionEmailAlerterTest.java
@@ -34,6 +34,7 @@ import org.apache.pinot.thirdeye.datasource.DAORegistry;
 import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 import org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterResult;
+import org.apache.pinot.thirdeye.detection.alert.filter.SubscriptionUtils;
 import org.apache.pinot.thirdeye.notification.commons.EmailEntity;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -92,7 +93,8 @@ public class DetectionEmailAlerterTest {
     this.alertConfigDTO.setName(ALERT_NAME_VALUE);
     Map<Long, Long> vectorClocks = new HashMap<>();
     this.alertConfigDTO.setVectorClocks(vectorClocks);
-    this.alertConfigDAO.save(this.alertConfigDTO);
+    long id = this.alertConfigDAO.save(this.alertConfigDTO);
+    this.alertConfigDTO.setId(id);
 
     MergedAnomalyResultDTO anomalyResultDTO = new MergedAnomalyResultDTO();
     anomalyResultDTO.setStartTime(1000L);
@@ -121,7 +123,7 @@ public class DetectionEmailAlerterTest {
   }
 
   @AfterMethod(alwaysRun = true)
-  void afterClass() {
+  void AfterMethod() {
     testDAOProvider.cleanup();
   }
 
@@ -134,8 +136,12 @@ public class DetectionEmailAlerterTest {
   @Test
   public void testSendEmailSuccessful() throws Exception {
     Map<DetectionAlertFilterNotification, Set<MergedAnomalyResultDTO>> result 
= new HashMap<>();
+    DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(
+        this.alertConfigDTO,
+        ConfigUtils.getMap(this.alertConfigDTO.getAlertSchemes()),
+        new HashMap<>());
     result.put(
-        new 
DetectionAlertFilterNotification(ConfigUtils.getMap(this.alertConfigDTO.getAlertSchemes())),
+        new DetectionAlertFilterNotification(subsConfig),
         new HashSet<>(this.anomalyDAO.findAll()));
     DetectionAlertFilterResult notificationResults = new 
DetectionAlertFilterResult(result);
 
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerterTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerterTest.java
index cf2b709..01d149a 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerterTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/scheme/DetectionJiraAlerterTest.java
@@ -35,6 +35,7 @@ import org.apache.pinot.thirdeye.datasource.DAORegistry;
 import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 import org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterResult;
+import org.apache.pinot.thirdeye.detection.alert.filter.SubscriptionUtils;
 import org.apache.pinot.thirdeye.notification.commons.JiraEntity;
 import org.apache.pinot.thirdeye.notification.commons.ThirdEyeJiraClient;
 import 
org.apache.pinot.thirdeye.notification.formatter.channels.TestJiraContentFormatter;
@@ -79,7 +80,8 @@ public class DetectionJiraAlerterTest {
     properties.put(PROP_DETECTION_CONFIG_IDS, 
Collections.singletonList(this.detectionConfigId));
 
     this.alertConfigDTO = 
TestJiraContentFormatter.createDimRecipientsDetectionAlertConfig(this.detectionConfigId);
-    this.alertConfigDAO.save(this.alertConfigDTO);
+    long id = this.alertConfigDAO.save(this.alertConfigDTO);
+    alertConfigDTO.setId(id);
 
     MergedAnomalyResultDTO anomalyResultDTO = new MergedAnomalyResultDTO();
     anomalyResultDTO.setStartTime(1000L);
@@ -123,10 +125,12 @@ public class DetectionJiraAlerterTest {
 
   @Test
   public void testUpdateJiraSuccessful() throws Exception {
+    DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(
+        this.alertConfigDTO,
+        ConfigUtils.getMap(this.alertConfigDTO.getAlertSchemes()),
+        new HashMap<>());
     Map<DetectionAlertFilterNotification, Set<MergedAnomalyResultDTO>> result 
= new HashMap<>();
-    result.put(
-        new 
DetectionAlertFilterNotification(ConfigUtils.getMap(this.alertConfigDTO.getAlertSchemes())),
-        new HashSet<>(this.anomalyDAO.findAll()));
+    result.put(new DetectionAlertFilterNotification(subsConfig), new 
HashSet<>(this.anomalyDAO.findAll()));
     DetectionAlertFilterResult notificationResults = new 
DetectionAlertFilterResult(result);
 
     final ThirdEyeJiraClient jiraClient = mock(ThirdEyeJiraClient.class);
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
index b945ca2..025dc62 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/detection/alert/suppress/DetectionTimeWindowSuppressorTest.java
@@ -3,6 +3,7 @@ package org.apache.pinot.thirdeye.detection.alert.suppress;
 import org.apache.pinot.thirdeye.datalayer.bao.DAOTestBase;
 import org.apache.pinot.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
 import org.apache.pinot.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
+import org.apache.pinot.thirdeye.detection.ConfigUtils;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterNotification;
 import 
org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterRecipients;
 import org.apache.pinot.thirdeye.detection.alert.DetectionAlertFilterResult;
@@ -14,6 +15,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import org.apache.pinot.thirdeye.detection.alert.filter.SubscriptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -116,13 +118,14 @@ public class DetectionTimeWindowSuppressorTest {
    */
   @Test
   public void testTimeWindowSuppressorWithThreshold() throws Exception {
-    Map<String, Set<String>> recipients = new HashMap<>();
+    Map<String, Object> recipients = new HashMap<>();
     recipients.put("to", Collections.singleton("test@test"));
 
     DetectionAlertFilterResult result = new DetectionAlertFilterResult();
-    Map<String, Object> alertProps = new HashMap<>();
-    alertProps.put("recipients", recipients);
-    result.addMapping(new DetectionAlertFilterNotification(alertProps), 
anomalies);
+    Map<String, Map<String, Object>> alertProps = new HashMap<>();
+    alertProps.put("emailScheme", recipients);
+    DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(alertProps);
+    result.addMapping(new DetectionAlertFilterNotification(subsConfig), 
anomalies);
 
     DetectionAlertTimeWindowSuppressor suppressor = new 
DetectionAlertTimeWindowSuppressor(config);
     DetectionAlertFilterResult resultsAfterSuppress = suppressor.run(result);
@@ -150,13 +153,14 @@ public class DetectionTimeWindowSuppressorTest {
     alertSuppressors.put(TIME_WINDOW_SUPPRESSOR_KEY, params);
     config.setAlertSuppressors(alertSuppressors);
 
-    Map<String, Set<String>> recipients = new HashMap<>();
+    Map<String, Object> recipients = new HashMap<>();
     recipients.put("to", Collections.singleton("test@test"));
 
     DetectionAlertFilterResult result = new DetectionAlertFilterResult();
-    Map<String, Object> alertProps = new HashMap<>();
-    alertProps.put("recipients", recipients);
-    result.addMapping(new DetectionAlertFilterNotification(alertProps), 
anomalies);
+    Map<String, Map<String, Object>> alertProps = new HashMap<>();
+    alertProps.put("emailScheme", recipients);
+    DetectionAlertConfigDTO subsConfig = 
SubscriptionUtils.makeChildSubscriptionConfig(alertProps);
+    result.addMapping(new DetectionAlertFilterNotification(subsConfig), 
anomalies);
 
     DetectionAlertTimeWindowSuppressor suppressor = new 
DetectionAlertTimeWindowSuppressor(config);
     DetectionAlertFilterResult resultsAfterSuppress = suppressor.run(result);
diff --git 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/tools/RunAdhocDatabaseQueriesTool.java
 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/tools/RunAdhocDatabaseQueriesTool.java
index ac54f41..5e2b74f 100644
--- 
a/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/tools/RunAdhocDatabaseQueriesTool.java
+++ 
b/thirdeye/thirdeye-pinot/src/test/java/org/apache/pinot/thirdeye/tools/RunAdhocDatabaseQueriesTool.java
@@ -462,10 +462,16 @@ public class RunAdhocDatabaseQueriesTool {
   private void disableAllActiveSubsGroups(Collection<Long> excludeIds){
     List<DetectionAlertConfigDTO> subsConfigs = 
detectionAlertConfigDAO.findAll();
     for (DetectionAlertConfigDTO subsConfig : subsConfigs) {
-      if (subsConfig.isActive() && (CollectionUtils.isEmpty(excludeIds) || 
!excludeIds
-          .contains(subsConfig.getId()))) {
-        subsConfig.setActive(false);
+      // Activate the whitelisted configs
+      if (excludeIds.contains(subsConfig.getId())) {
+        subsConfig.setActive(true);
         detectionAlertConfigDAO.update(subsConfig);
+      } else {
+        // Disable other configs
+        if (subsConfig.isActive()) {
+          subsConfig.setActive(false);
+          detectionAlertConfigDAO.update(subsConfig);
+        }
       }
     }
   }
@@ -612,7 +618,7 @@ public class RunAdhocDatabaseQueriesTool {
       System.exit(1);
     }
     RunAdhocDatabaseQueriesTool dq = new 
RunAdhocDatabaseQueriesTool(persistenceFile);
-    dq.unsubscribedDetections();
+    dq.disableAllActiveSubsGroups(Collections.singleton(142644400L));
     LOG.info("DONE");
   }
 


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

Reply via email to