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

[GitHub] apucher closed pull request #3473: [TE] Ability to configure reference links like oncall run-book in the email alert

apucher closed pull request #3473: [TE] Ability to configure reference links like oncall run-book in the email alert
URL: https://github.com/apache/incubator-pinot/pull/3473
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 bd7651867b..d0c76571b7 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 @@ protected abstract void updateTemplateDataByAnomalyResults(Map<String, Object> t
       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 1274056d1d..dd8f85cb75 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 @@
   DetectionAlertFilterRecipients receiverAddresses;
   String fromAddress;
   SubjectType subjectType = SubjectType.ALERT;
+  Map<String, String> refLinks;
 
   public String getApplication() {
     return application;
@@ -154,6 +155,14 @@ public void setSubjectType(SubjectType subjectType) {
     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 b4c335c02f..5d4c825ba2 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 @@
 
   Map<String, Object> properties;
 
+  Map<String, String> refLinks;
+
   public boolean isActive() {
     return active;
   }
@@ -134,6 +136,14 @@ public void setAlertSuppressors(Map<String, Map<String, Object>> alertSuppressor
     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 95fdb0e191..97495f1f9d 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 @@ private void sendEmail(DetectionAlertFilterRecipients recipients, Set<MergedAnom
     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 bc789bc616..0b13c7828a 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 0000000000..020a343a7c
--- /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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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