You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ji...@apache.org on 2019/01/10 19:14:45 UTC
[incubator-pinot] branch master updated: [TE] Endpoint to return
the anomalies for a detection config within a range (#3670)
This is an automated email from the ASF dual-hosted git repository.
jihao 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 36bbdf1 [TE] Endpoint to return the anomalies for a detection config within a range (#3670)
36bbdf1 is described below
commit 36bbdf10d18e98fed67c57f9f5835f33c71e9803
Author: Jihao Zhang <ji...@linkedin.com>
AuthorDate: Thu Jan 10 11:14:40 2019 -0800
[TE] Endpoint to return the anomalies for a detection config within a range (#3670)
The endpoint to return the anomalies for a detection config within a time range.
---
.../linkedin/thirdeye/detection/DetectionResource.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionResource.java b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionResource.java
index 8eea427..0f3c22d 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/DetectionResource.java
@@ -17,6 +17,8 @@
package com.linkedin.thirdeye.detection;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
+import com.linkedin.pinot.common.utils.ServiceStatus;
import com.linkedin.thirdeye.api.Constants;
import com.linkedin.thirdeye.constant.AnomalyResultSource;
import com.linkedin.thirdeye.datalayer.bao.DatasetConfigManager;
@@ -25,9 +27,11 @@ import com.linkedin.thirdeye.datalayer.bao.DetectionConfigManager;
import com.linkedin.thirdeye.datalayer.bao.EventManager;
import com.linkedin.thirdeye.datalayer.bao.MergedAnomalyResultManager;
import com.linkedin.thirdeye.datalayer.bao.MetricConfigManager;
+import com.linkedin.thirdeye.datalayer.dto.AbstractDTO;
import com.linkedin.thirdeye.datalayer.dto.DetectionAlertConfigDTO;
import com.linkedin.thirdeye.datalayer.dto.DetectionConfigDTO;
import com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO;
+import com.linkedin.thirdeye.datalayer.util.Predicate;
import com.linkedin.thirdeye.datasource.DAORegistry;
import com.linkedin.thirdeye.datasource.ThirdEyeCacheRegistry;
import com.linkedin.thirdeye.datasource.loader.AggregationLoader;
@@ -51,6 +55,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -58,11 +63,13 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.collections.MapUtils;
import org.joda.time.DateTime;
import org.joda.time.Interval;
+import org.joda.time.format.ISODateTimeFormat;
import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -146,6 +153,17 @@ public class DetectionResource {
return Response.ok(detectionAlertConfigDTOs).build();
}
+ @Path("{id}/anomalies")
+ @GET
+ @ApiOperation("Get all anomalies within the time range for a detection config id")
+ public Response getAnomalies(@PathParam("id") Long detectionConfigId, @QueryParam("start") long startTime,
+ @QueryParam("end") long endTime) {
+ List<MergedAnomalyResultDTO> anomalies = this.anomalyDAO.findByPredicate(Predicate.AND(
+ Predicate.EQ("detectionConfigId", detectionConfigId),
+ Predicate.LT("startTime", endTime),
+ Predicate.GT("endTime", startTime)));
+ return Response.ok(anomalies).build();
+ }
@POST
@Path("/preview")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org