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/02/26 00:25:23 UTC

[incubator-pinot] branch master updated: [TE] Include alert description in the email (#3879)

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 126b022  [TE] Include alert description in the email (#3879)
126b022 is described below

commit 126b022070a5d2dabf957552dcea7de733accf80
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Mon Feb 25 16:25:18 2019 -0800

    [TE] Include alert description in the email (#3879)
---
 .../thirdeye/alert/content/BaseEmailContentFormatter.java   | 13 ++++++++++++-
 .../content/HierarchicalAnomaliesEmailContentFormatter.java |  2 ++
 .../content/MultipleAnomaliesEmailContentFormatter.java     |  4 +++-
 .../pinot/thirdeye/detector/holiday-anomaly-report.ftl      |  5 ++++-
 .../test-multiple-anomalies-email-content-formatter.html    |  4 +++-
 5 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/BaseEmailContentFormatter.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/BaseEmailContentFormatter.java
index 4b61ed3..e87408b 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/BaseEmailContentFormatter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/BaseEmailContentFormatter.java
@@ -586,6 +586,7 @@ public abstract class BaseEmailContentFormatter implements EmailContentFormatter
     List<String> dimensions;
     String swi;
     String function;
+    String funcDescription;
     String duration;
     String startTime;
     String endTime;
@@ -596,7 +597,7 @@ public abstract class BaseEmailContentFormatter implements EmailContentFormatter
     private static String PERCENTAGE_FORMAT = "%.2f %%";
 
     public AnomalyReportEntity(String anomalyId, String anomalyURL, String baselineVal, String currentVal, Double swi,
-        List<String> dimensions, String duration, String feedback, String function,
+        List<String> dimensions, String duration, String feedback, String function, String funcDescription,
         String metric, String startTime, String endTime, String timezone, String issueType) {
       this.anomalyId = anomalyId;
       this.anomalyURL = anomalyURL;
@@ -606,6 +607,7 @@ public abstract class BaseEmailContentFormatter implements EmailContentFormatter
       this.duration = duration;
       this.feedback = feedback;
       this.function = function;
+      this.funcDescription = funcDescription;
       this.swi = "";
       if (swi != null) {
         this.swi = String.format(PERCENTAGE_FORMAT, swi * 100);
@@ -694,6 +696,15 @@ public abstract class BaseEmailContentFormatter implements EmailContentFormatter
     public void setFunction(String function) {
       this.function = function;
     }
+
+    public String getFuncDescription() {
+      return funcDescription;
+    }
+
+    public void setFuncDescription(String funcDescription) {
+      this.funcDescription = funcDescription;
+    }
+
     public String getAnomalyId() {
       return anomalyId;
     }
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/HierarchicalAnomaliesEmailContentFormatter.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/HierarchicalAnomaliesEmailContentFormatter.java
index 9457039..d3dbf3e 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/HierarchicalAnomaliesEmailContentFormatter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/HierarchicalAnomaliesEmailContentFormatter.java
@@ -51,6 +51,7 @@ import org.slf4j.LoggerFactory;
  * The top-level anomalies are defined as anomalies generated by anomaly function without dimension drill-down; otherwise,
  * it is in the lower-level anomalies. The content formatter takes hierarchical-anomalies-email-template.ftl in default.
  */
+@Deprecated
 public class HierarchicalAnomaliesEmailContentFormatter extends BaseEmailContentFormatter{
   private static final Logger LOG = LoggerFactory.getLogger(HierarchicalAnomaliesEmailContentFormatter.class);
 
@@ -145,6 +146,7 @@ public class HierarchicalAnomaliesEmailContentFormatter extends BaseEmailContent
         getTimeDiffInHours(anomaly.getStartTime(), anomaly.getEndTime()), // duration
         feedbackVal,
         anomaly.getFunction().getFunctionName(),
+        "",
         anomaly.getMetric(),
         getDateString(anomaly.getStartTime(), dateTimeZone),
         getDateString(anomaly.getEndTime(), dateTimeZone),
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java
index 2763378..e0e6e43 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java
@@ -114,6 +114,7 @@ public class MultipleAnomaliesEmailContentFormatter extends BaseEmailContentForm
       String feedbackVal = getFeedbackValue(feedback);
 
       String functionName = "Alerts";
+      String funcDescription = "";
       Long id = -1L;
 
       if (anomaly.getFunction() != null){
@@ -123,10 +124,10 @@ public class MultipleAnomaliesEmailContentFormatter extends BaseEmailContentForm
         DetectionConfigDTO config = this.configDAO.findById(anomaly.getDetectionConfigId());
         Preconditions.checkNotNull(config, String.format("Cannot find detection config %d", anomaly.getDetectionConfigId()));
         functionName = config.getName();
+        funcDescription = config.getDescription();
         id = config.getId();
       }
 
-
       AnomalyReportEntity anomalyReport = new AnomalyReportEntity(String.valueOf(anomaly.getId()),
           getAnomalyURL(anomaly, emailContentFormatterConfiguration.getDashboardHost()),
           ThirdEyeUtils.getRoundedValue(anomaly.getAvgBaselineVal()),
@@ -136,6 +137,7 @@ public class MultipleAnomaliesEmailContentFormatter extends BaseEmailContentForm
           getTimeDiffInHours(anomaly.getStartTime(), anomaly.getEndTime()), // duration
           feedbackVal,
           functionName,
+          funcDescription,
           anomaly.getMetric(),
           getDateString(anomaly.getStartTime(), dateTimeZone),
           getDateString(anomaly.getEndTime(), dateTimeZone),
diff --git a/thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/holiday-anomaly-report.ftl b/thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/holiday-anomaly-report.ftl
index f161fba..9047843 100644
--- a/thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/holiday-anomaly-report.ftl
+++ b/thirdeye/thirdeye-pinot/src/main/resources/org/apache/pinot/thirdeye/detector/holiday-anomaly-report.ftl
@@ -70,12 +70,15 @@
                   <#list functionAnomalyDetails[function] as anomaly>
                     <#if anomaly.metric==metric>
                       <#assign newTable=true>
+                      <#assign description=anomaly.funcDescription>
                     </#if>
                   </#list>
                   <#if newTable>
                   <p>
                     <span style="color: #606060;">Alert</span>
-                    <a href="${dashboardHost}/app/#/manage/alert/${functionToId[function]?string.computer}" target="blank" style="text-decoration: none; color: #0B5EA1; font-weight: bold;">${function}</a>
+                    <span style="color: #1D1D1D; text-decoration: none;  font-weight: bold;">${function}</span>
+                    <a href="${dashboardHost}/app/#/manage/alert/${functionToId[function]?string.computer}" target="blank" style="text-decoration: none; color: #0B5EA1; font-weight: bold;">(View/Edit Alert)</a>
+                    <span style="color: #1D1D1D; text-decoration: none;">${description}</span>
                   </p>
                   </#if>
                   <table border="0" width="100%" align="center" style="width:100%; padding:0; margin:0; border-collapse: collapse;text-align:left;">
diff --git a/thirdeye/thirdeye-pinot/src/test/resources/test-multiple-anomalies-email-content-formatter.html b/thirdeye/thirdeye-pinot/src/test/resources/test-multiple-anomalies-email-content-formatter.html
index 50a39bb..b71519a 100644
--- a/thirdeye/thirdeye-pinot/src/test/resources/test-multiple-anomalies-email-content-formatter.html
+++ b/thirdeye/thirdeye-pinot/src/test/resources/test-multiple-anomalies-email-content-formatter.html
@@ -36,7 +36,9 @@
             </p>
             <p>
               <span style="color: #606060;">Alert</span>
-              <a href="http://localhost:8080/dashboard/app/#/manage/alert/1" target="blank" style="text-decoration: none; color: #0B5EA1; font-weight: bold;">integration test function 1</a>
+              <span style="color: #1D1D1D; text-decoration: none;  font-weight: bold;">integration test function 1</span>
+              <a href="http://localhost:8080/dashboard/app/#/manage/alert/1" target="blank" style="text-decoration: none; color: #0B5EA1; font-weight: bold;">(View/Edit Alert)</a>
+              <span style="color: #1D1D1D; text-decoration: none;"></span>
             </p>
             <table border="0" width="100%" align="center" style="width:100%; padding:0; margin:0; border-collapse: collapse;text-align:left;">
               <tr style="text-align:center; background-color: #F6F8FA; border-top: 2px solid #C7D1D8; border-bottom: 2px solid #C7D1D8;">


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org