You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2019/07/26 17:24:49 UTC
[incubator-pinot] branch master updated: [TE] Include admin
recipients in every email alert (cc address) (#4470)
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 29bc069 [TE] Include admin recipients in every email alert (cc address) (#4470)
29bc069 is described below
commit 29bc069bd88f4f96fe547d68ee3c81e3a02df9ac
Author: Akshay Rai <ak...@linkedin.com>
AuthorDate: Fri Jul 26 10:24:43 2019 -0700
[TE] Include admin recipients in every email alert (cc address) (#4470)
---
.../alert/scheme/DetectionEmailAlerter.java | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
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 7cef8f8..87d0c0b 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
@@ -20,6 +20,7 @@
package org.apache.pinot.thirdeye.detection.alert.scheme;
import com.google.common.base.Preconditions;
+import java.util.HashSet;
import org.apache.pinot.thirdeye.alert.commons.EmailContentFormatterFactory;
import org.apache.pinot.thirdeye.alert.commons.EmailEntity;
import org.apache.pinot.thirdeye.alert.content.EmailContentFormatter;
@@ -62,7 +63,10 @@ public class DetectionEmailAlerter extends DetectionAlertScheme {
private static final Comparator<AnomalyResult> COMPARATOR_DESC =
(o1, o2) -> -1 * Long.compare(o1.getStartTime(), o2.getStartTime());
- private static final String EMAIL_WHITELIST_KEY = "emailWhitelist";
+
+ private static final String PROP_EMAIL_WHITELIST = "emailWhitelist";
+ private static final String PROP_ADMIN_RECIPIENTS = "adminRecipients";
+
private static final String PROP_EMAIL_SCHEME = "emailScheme";
private static final String PROP_EMAIL_TEMPLATE = "template";
private static final String PROP_EMAIL_SUBJECT_STYLE = "subject";
@@ -86,7 +90,7 @@ public class DetectionEmailAlerter extends DetectionAlertScheme {
private void whitelistRecipients(DetectionAlertFilterRecipients recipients) {
if (recipients != null) {
List<String> emailWhitelist = ConfigUtils.getList(
- this.teConfig.getAlerterConfiguration().get(SMTP_CONFIG_KEY).get(EMAIL_WHITELIST_KEY));
+ this.teConfig.getAlerterConfiguration().get(SMTP_CONFIG_KEY).get(PROP_EMAIL_WHITELIST));
if (!emailWhitelist.isEmpty()) {
recipients.setTo(retainWhitelisted(recipients.getTo(), emailWhitelist));
recipients.setCc(retainWhitelisted(recipients.getCc(), emailWhitelist));
@@ -198,15 +202,15 @@ public class DetectionEmailAlerter extends DetectionAlertScheme {
new EmailContentFormatterContext());
HtmlEmail email = emailEntity.getContent();
+ email.setSubject(emailEntity.getSubject());
email.setFrom(this.config.getFrom());
email.setTo(AlertUtils.toAddress(recipients.getTo()));
- email.setSubject(emailEntity.getSubject());
- if (CollectionUtils.isNotEmpty(recipients.getCc())) {
- email.setCc(AlertUtils.toAddress(recipients.getCc()));
- }
- if (CollectionUtils.isNotEmpty(recipients.getBcc())) {
- email.setBcc(AlertUtils.toAddress(recipients.getBcc()));
+ if (recipients.getCc() == null) {
+ recipients.setCc(new HashSet<>());
}
+ recipients.getCc().addAll(ConfigUtils.getList(this.teConfig.getAlerterConfiguration().get(PROP_ADMIN_RECIPIENTS)));
+ email.setCc(AlertUtils.toAddress(recipients.getCc()));
+ email.setBcc(AlertUtils.toAddress(recipients.getBcc()));
sendEmail(emailEntity);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org