You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ap...@apache.org on 2018/11/13 23:12:25 UTC

[incubator-pinot] branch master updated: [TE] Ability to configure reference links like oncall run-book in the email alert (#3473)

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

apucher 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 a7df756  [TE] Ability to configure reference links like oncall run-book in the email alert (#3473)
a7df756 is described below

commit a7df756eeaf31ce9485b5e6412e69a747746aaca
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Tue Nov 13 15:12:21 2018 -0800

    [TE] Ability to configure reference links like oncall run-book in the email alert (#3473)
---
 .../alert/content/BaseEmailContentFormatter.java   |  3 +++
 .../thirdeye/datalayer/pojo/AlertConfigBean.java   |  9 +++++++
 .../datalayer/pojo/DetectionAlertConfigBean.java   | 10 ++++++++
 .../alert/scheme/DetectionEmailAlerter.java        |  1 +
 .../thirdeye/detector/holiday-anomaly-report.ftl   | 30 +++++++++++++---------
 .../com/linkedin/thirdeye/detector/lib/utils.ftl   | 12 +++++++++
 6 files changed, 53 insertions(+), 12 deletions(-)

diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/BaseEmailContentFormatter.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/BaseEmailContentFormatter.java
index bd76518..d0c7657 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/BaseEmailContentFormatter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/BaseEmailContentFormatter.java
@@ -271,6 +271,9 @@ public abstract class BaseEmailContentFormatter implements EmailContentFormatter
       templateData.put("recall", precisionRecallEvaluator.getRecall());
       templateData.put("falseNegative", precisionRecallEvaluator.getFalseNegativeRate());
     }
+    if (alertConfigDTO.getReferenceLinks() != null) {
+      templateData.put("referenceLinks", alertConfigDTO.getReferenceLinks());
+    }
 
     return templateData;
   }
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/AlertConfigBean.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/AlertConfigBean.java
index 1274056..dd8f85c 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/AlertConfigBean.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/AlertConfigBean.java
@@ -49,6 +49,7 @@ public class AlertConfigBean extends AbstractBean {
   DetectionAlertFilterRecipients receiverAddresses;
   String fromAddress;
   SubjectType subjectType = SubjectType.ALERT;
+  Map<String, String> refLinks;
 
   public String getApplication() {
     return application;
@@ -154,6 +155,14 @@ public class AlertConfigBean extends AbstractBean {
     this.subjectType = subjectType;
   }
 
+  public Map<String, String> getReferenceLinks() {
+    return refLinks;
+  }
+
+  public void setReferenceLinks(Map<String, String> refLinks) {
+    this.refLinks = refLinks;
+  }
+
   @JsonIgnoreProperties(ignoreUnknown = true)
   public static class EmailConfig {
     long anomalyWatermark = 0l;
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
index b4c335c..5d4c825 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/pojo/DetectionAlertConfigBean.java
@@ -46,6 +46,8 @@ public class DetectionAlertConfigBean extends AbstractBean {
 
   Map<String, Object> properties;
 
+  Map<String, String> refLinks;
+
   public boolean isActive() {
     return active;
   }
@@ -134,6 +136,14 @@ public class DetectionAlertConfigBean extends AbstractBean {
     this.alertSuppressors = alertSuppressors;
   }
 
+  public Map<String, String> getReferenceLinks() {
+    return refLinks;
+  }
+
+  public void setReferenceLinks(Map<String, String> refLinks) {
+    this.refLinks = refLinks;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
index 95fdb0e..97495f1 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/scheme/DetectionEmailAlerter.java
@@ -137,6 +137,7 @@ public class DetectionEmailAlerter extends DetectionAlertScheme {
     alertConfig.setName(this.config.getName());
     alertConfig.setFromAddress(this.config.getFrom());
     alertConfig.setSubjectType(this.config.getSubjectType());
+    alertConfig.setReferenceLinks(this.config.getReferenceLinks());
 
     EmailEntity emailEntity = emailContentFormatter.getEmailEntity(alertConfig, null,
         "Thirdeye Alert : " + this.config.getName(), null, null, anomalyResultListOfGroup,
diff --git a/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/holiday-anomaly-report.ftl b/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/holiday-anomaly-report.ftl
index bc789bc..0b13c78 100644
--- a/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/holiday-anomaly-report.ftl
+++ b/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/holiday-anomaly-report.ftl
@@ -1,3 +1,5 @@
+<#import "lib/utils.ftl" as utils>
+
 <head>
   <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
 </head>
@@ -58,8 +60,7 @@
           </#if>
 
           <#list metricAnomalyDetails?keys as metric>
-            <tr>
-              <td style="border-bottom: 1px solid rgba(0,0,0,0.15); padding: 24px; font-family:'Proxima Nova','Arial', 'Helvetica Neue',Helvetica, sans-serif;" colspan="2" align="left">
+            <@utils.addRow title="" align="left">
                 <p style="margin-left: 24px;">
                   <span style="color: #606060; font-size: 20px; line-height: 24px; margin-right: 16px;">Metric</span>
                   <span style="color: #1D1D1D; font-size: 20px; font-weight: bold; line-height: 24px;">${metric}</span>
@@ -113,15 +114,22 @@
                     </#list>
                   </table>
                 </#list>
-              </td>
-            </tr>
+            </...@utils.addRow>
           </#list>
 
+          <#if referenceLinks?has_content>
+            <@utils.addRow title="Useful Links" align="center">
+              <#list referenceLinks?keys as referenceLinkKey>
+                <div style="padding-top: 16px;">
+                  <a href="${referenceLinks[referenceLinkKey]}" style="text-decoration: none; color:#0073B1; font-size:14px; font-weight:bold; line-height:20px; margin-bottom: 0;">${referenceLinkKey}</a>
+                </div>
+              </#list>
+            </...@utils.addRow>
+          </#if>
+
           <#if holidays?has_content>
-            <tr>
-              <td style="padding: 24px; font-family:'Proxima Nova','Arial', 'Helvetica Neue',Helvetica, sans-serif;" colspan="2" align="center">
-                <p style="font-size:20px; line-height:24px; color:#1D1D1D; font-weight: 500; margin:0; padding:0;">Holidays</p>
-                <#list holidays as holiday>
+            <@utils.addRow title="Holidays" align="center">
+              <#list holidays as holiday>
                   <div style="padding-top: 16px;">
                     <a href="https://www.google.com/search?q=${holiday.name}" style="text-decoration: none; color:#0073B1; font-size:14px; font-weight:bold; line-height:20px; margin-bottom: 0;">${holiday.name}</a>
                     <span style="font-size: 14px; color:#606060; line-height:20px;">(${holiday.startTime?number_to_date})</span>
@@ -131,12 +139,10 @@
                         <span style="color: rgba(0,0,0,0.6); line-height:16px; font-size: 12px;">${holiday.targetDimensionMap[dimension]?join(",")}</span>
                     </#list>
                   </#if>
-                </#list>
-              </td>
-            </tr>
+              </#list>
+            </...@utils.addRow>
           </#if>
 
-
         <tr>
           <td colspan="2" style="border-bottom: 1px solid #E9E9E9;">
           </td>
diff --git a/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/lib/utils.ftl b/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/lib/utils.ftl
new file mode 100644
index 0000000..020a343
--- /dev/null
+++ b/thirdeye/thirdeye-pinot/src/main/resources/com/linkedin/thirdeye/detector/lib/utils.ftl
@@ -0,0 +1,12 @@
+<#macro addRow title align>
+    <tr>
+      <td style="border-bottom: 1px solid rgba(0,0,0,0.15); padding: 24px; font-family:'Proxima Nova','Arial', 'Helvetica Neue',Helvetica, sans-serif;" colspan="2" align="${align}">
+        <#if title?has_content>
+          <p style="font-size:20px; line-height:24px; color:#1D1D1D; font-weight: 500; margin:0; padding:0;">${title}</p>
+        </#if>
+
+        <#nested>
+
+      </td>
+    </tr>
+</#macro>
\ No newline at end of file


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