Search in sources :

Example 26 with AnomalyFunctionDTO

use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.

the class FetchMetricDataAndExistingAnomaliesTool method fetchRawAnomaliesInRangeByFunctionId.

public List<ResultNode> fetchRawAnomaliesInRangeByFunctionId(long functionId, DateTime startTime, DateTime endTime) {
    AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(functionId);
    LOG.info(String.format("Loading raw anaomaly results of functionId {} from db...", Long.toString(functionId)));
    List<ResultNode> resultNodes = new ArrayList<>();
    if (anomalyFunction == null) {
        // no such function
        return resultNodes;
    }
    List<RawAnomalyResultDTO> rawResults = rawAnomalyResultDAO.findAllByTimeAndFunctionId(startTime.getMillis(), endTime.getMillis(), functionId);
    for (RawAnomalyResultDTO rawResult : rawResults) {
        ResultNode res = new ResultNode();
        res.functionId = functionId;
        res.functionName = anomalyFunction.getFunctionName();
        res.startTime = new DateTime(rawResult.getStartTime());
        res.endTime = new DateTime(rawResult.getEndTime());
        res.dimensions = rawResult.getDimensions();
        res.setFilters(anomalyFunction.getFilters());
        res.severity = rawResult.getWeight();
        AnomalyFeedbackDTO feedback = rawResult.getFeedback();
        res.feedbackType = (feedback == null) ? null : feedback.getFeedbackType();
        resultNodes.add(res);
    }
    return resultNodes;
}
Also used : RawAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO) ArrayList(java.util.ArrayList) AnomalyFeedbackDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) DateTime(org.joda.time.DateTime)

Example 27 with AnomalyFunctionDTO

use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.

the class FetchMetricDataAndExistingAnomaliesTool method fetchMergedAnomaliesInRange.

/**
   * Fetch merged anomaly results from thirdeye db
   * @param collection database/collection name
   * @param metric metric name
   * @param startTime start time of the requested data in DateTime format
   * @param endTime end time of the requested data in DateTime format
   * @return List of merged anomaly results
   */
public List<ResultNode> fetchMergedAnomaliesInRange(String collection, String metric, DateTime startTime, DateTime endTime) {
    List<AnomalyFunctionDTO> anomalyFunctions = anomalyFunctionDAO.findAllByCollection(collection);
    LOG.info("Loading merged anaomaly results from db...");
    List<ResultNode> resultNodes = new ArrayList<>();
    for (AnomalyFunctionDTO anomalyDto : anomalyFunctions) {
        if (!anomalyDto.getTopicMetric().equals(metric))
            continue;
        resultNodes.addAll(fetchMergedAnomaliesInRangeByFunctionId(anomalyDto.getId(), startTime, endTime));
    }
    Collections.sort(resultNodes);
    return resultNodes;
}
Also used : ArrayList(java.util.ArrayList) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Example 28 with AnomalyFunctionDTO

use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.

the class FetchMetricDataAndExistingAnomaliesTool method fetchMergedAnomaliesInRangeByFunctionId.

public List<ResultNode> fetchMergedAnomaliesInRangeByFunctionId(long functionId, DateTime startTime, DateTime endTime) {
    AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(functionId);
    LOG.info("Loading merged anaomaly results of functionId {} from db...", functionId);
    List<ResultNode> resultNodes = new ArrayList<>();
    if (anomalyFunction == null) {
        // no such function
        return resultNodes;
    }
    List<MergedAnomalyResultDTO> mergedResults = mergedAnomalyResultDAO.findByStartTimeInRangeAndFunctionId(startTime.getMillis(), endTime.getMillis(), functionId);
    for (MergedAnomalyResultDTO mergedResult : mergedResults) {
        ResultNode res = new ResultNode();
        res.functionId = functionId;
        res.functionName = anomalyFunction.getFunctionName();
        res.startTime = new DateTime(mergedResult.getStartTime());
        res.endTime = new DateTime(mergedResult.getEndTime());
        res.dimensions = mergedResult.getDimensions();
        res.setFilters(anomalyFunction.getFilters());
        res.severity = mergedResult.getWeight();
        AnomalyFeedbackDTO feedback = mergedResult.getFeedback();
        res.feedbackType = (feedback == null) ? null : feedback.getFeedbackType();
        resultNodes.add(res);
    }
    return resultNodes;
}
Also used : MergedAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO) ArrayList(java.util.ArrayList) AnomalyFeedbackDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) DateTime(org.joda.time.DateTime)

Example 29 with AnomalyFunctionDTO

use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.

the class TestAnomalyFunctionManager method testDelete.

@Test(dependsOnMethods = { "testUpdate" })
public void testDelete() {
    anomalyFunctionDAO.deleteById(anomalyFunctionId);
    AnomalyFunctionDTO spec = anomalyFunctionDAO.findById(anomalyFunctionId);
    Assert.assertNull(spec);
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) Test(org.testng.annotations.Test)

Example 30 with AnomalyFunctionDTO

use of com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO in project pinot by linkedin.

the class RunAdhocDatabaseQueriesTool method updateField.

private void updateField(Long id) {
    AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(id);
    //anomalyFunction.setCron("0/10 * * * * ?");
    anomalyFunction.setActive(true);
    anomalyFunctionDAO.update(anomalyFunction);
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Aggregations

AnomalyFunctionDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)74 ArrayList (java.util.ArrayList)23 DateTime (org.joda.time.DateTime)20 RawAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO)19 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)17 Test (org.testng.annotations.Test)16 Path (javax.ws.rs.Path)11 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)9 POST (javax.ws.rs.POST)8 AnomalyDetectionContext (com.linkedin.thirdeye.anomalydetection.context.AnomalyDetectionContext)7 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)7 EmailConfigurationDTO (com.linkedin.thirdeye.datalayer.dto.EmailConfigurationDTO)7 AnomalyFunctionBean (com.linkedin.thirdeye.datalayer.pojo.AnomalyFunctionBean)6 Interval (org.joda.time.Interval)6 MetricTimeSeries (com.linkedin.thirdeye.api.MetricTimeSeries)5 AnomalyFeedbackDTO (com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO)5 DetectionStatusDTO (com.linkedin.thirdeye.datalayer.dto.DetectionStatusDTO)5 ScalingFactor (com.linkedin.thirdeye.detector.metric.transfer.ScalingFactor)5 HashMap (java.util.HashMap)5 NullArgumentException (org.apache.commons.lang.NullArgumentException)5