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 2018/11/27 23:00:26 UTC

[incubator-pinot] branch master updated: [TE] Make new alerter tag old anomalies as notified (#3554)

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 61b4814  [TE] Make new alerter tag old anomalies as notified (#3554)
61b4814 is described below

commit 61b4814cca55ad18c9270a5fd402003859a48c07
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Tue Nov 27 15:00:20 2018 -0800

    [TE] Make new alerter tag old anomalies as notified (#3554)
    
    The current UI relies on notified tag to fetch and display the anomalies.Due to this behavior, when an old pipeline anomaly is alerted using the new alerter it doesn't show up on the UI. The notified tag needs to be cleaned up after the migration.
---
 .../alert/content/MultipleAnomaliesEmailContentFormatter.java |  4 +++-
 .../com/linkedin/thirdeye/anomaly/events/EventFilter.java     |  7 +++++++
 .../thirdeye/anomaly/events/HolidayEventProvider.java         |  3 ++-
 .../thirdeye/detection/alert/DetectionAlertTaskRunner.java    | 11 +++++++++++
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java
index dd82847..88695c0 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/alert/content/MultipleAnomaliesEmailContentFormatter.java
@@ -160,7 +160,9 @@ public class MultipleAnomaliesEmailContentFormatter extends BaseEmailContentForm
     final DateTime eventStart = windowStart.minus(preEventCrawlOffset);
     final DateTime eventEnd = windowEnd.plus(postEventCrawlOffset);
     Map<String, List<String>> targetDimensions = new HashMap<>();
-    targetDimensions.put(EVENT_FILTER_COUNTRY, emailContentFormatterConfiguration.getHolidayCountriesWhitelist());
+    if (emailContentFormatterConfiguration.getHolidayCountriesWhitelist() != null) {
+      targetDimensions.put(EVENT_FILTER_COUNTRY, emailContentFormatterConfiguration.getHolidayCountriesWhitelist());
+    }
     List<EventDTO> holidays = getHolidayEvents(eventStart, eventEnd, targetDimensions);
     Collections.sort(holidays, new Comparator<EventDTO>() {
       @Override
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/EventFilter.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/EventFilter.java
index f61826f..1dda232 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/EventFilter.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/EventFilter.java
@@ -27,8 +27,13 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 
 import com.linkedin.thirdeye.datalayer.dto.EventDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 public class EventFilter {
+  private static final Logger LOG = LoggerFactory.getLogger(EventFilter.class);
+
   String eventType;
   String serviceName;
   String metricName;
@@ -152,6 +157,8 @@ public class EventFilter {
         filteredEvents.addAll(allEvents);
       }
     }
+
+    LOG.info("Whitelisting complete. Returning {} fetched events after whitelist", filteredEvents.size());
     return filteredEvents;
   }
 
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/HolidayEventProvider.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/HolidayEventProvider.java
index 6455823..d43cae3 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/HolidayEventProvider.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/events/HolidayEventProvider.java
@@ -32,12 +32,13 @@ public class HolidayEventProvider implements EventDataProvider<EventDTO> {
 
   @Override
   public List<EventDTO> getEvents(EventFilter eventFilter) {
-    LOG.info("Fetching all {} events between {} and {}", eventFilter.getEventType(), eventFilter.getStartTime(), eventFilter.getEndTime());
     List<EventDTO> allEventsBetweenTimeRange = eventDAO.findEventsBetweenTimeRange(
         eventFilter.getEventType(),
         eventFilter.getStartTime(),
         eventFilter.getEndTime());
 
+    LOG.info("Fetched {} {} events between {} and {}", allEventsBetweenTimeRange.size(),
+        eventFilter.getEventType(), eventFilter.getStartTime(), eventFilter.getEndTime());
     return EventFilter.applyDimensionFilter(allEventsBetweenTimeRange, eventFilter.getTargetDimensionMap());
   }
 
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/DetectionAlertTaskRunner.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/DetectionAlertTaskRunner.java
index 50285cf..c88263c 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/DetectionAlertTaskRunner.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/alert/DetectionAlertTaskRunner.java
@@ -23,8 +23,10 @@ import com.linkedin.thirdeye.anomaly.task.TaskRunner;
 import com.linkedin.thirdeye.anomaly.utils.ThirdeyeMetricsUtil;
 import com.linkedin.thirdeye.datalayer.bao.DatasetConfigManager;
 import com.linkedin.thirdeye.datalayer.bao.DetectionAlertConfigManager;
+import com.linkedin.thirdeye.datalayer.bao.MergedAnomalyResultManager;
 import com.linkedin.thirdeye.datalayer.bao.MetricConfigManager;
 import com.linkedin.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
+import com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
 import com.linkedin.thirdeye.datasource.DAORegistry;
 import com.linkedin.thirdeye.datasource.ThirdEyeCacheRegistry;
 import com.linkedin.thirdeye.datasource.loader.AggregationLoader;
@@ -49,10 +51,12 @@ public class DetectionAlertTaskRunner implements TaskRunner {
   private final DetectionAlertTaskFactory detAlertTaskFactory;
   private CurrentAndBaselineLoader currentAndBaselineLoader;
   private DetectionAlertConfigManager alertConfigDAO;
+  private MergedAnomalyResultManager mergedAnomalyDAO;
 
   public DetectionAlertTaskRunner() {
     this.detAlertTaskFactory = new DetectionAlertTaskFactory();
     this.alertConfigDAO = DAORegistry.getInstance().getDetectionAlertConfigManager();
+    this.mergedAnomalyDAO = DAORegistry.getInstance().getMergedAnomalyResultDAO();
 
     DatasetConfigManager datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
     MetricConfigManager metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
@@ -102,6 +106,13 @@ public class DetectionAlertTaskRunner implements TaskRunner {
       DetectionAlertFilter alertFilter = detAlertTaskFactory.loadAlertFilter(alertConfig, System.currentTimeMillis());
       DetectionAlertFilterResult result = alertFilter.run();
 
+      // TODO: The old UI relies on notified tag to display the anomalies. After the migration
+      // we need to clean up all references to notified tag.
+      for (MergedAnomalyResultDTO anomaly : result.getAllAnomalies()) {
+        anomaly.setNotified(true);
+        mergedAnomalyDAO.update(anomaly);
+      }
+
       // Suppress alerts if any and get the filtered anomalies to be notified
       Set<DetectionAlertSuppressor> alertSuppressors = detAlertTaskFactory.loadAlertSuppressors(alertConfig);
       for (DetectionAlertSuppressor alertSuppressor : alertSuppressors) {


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