Search in sources :

Example 31 with AnomalyFunctionDTO

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

the class RunAdhocDatabaseQueriesTool method customFunction.

private void customFunction() {
    List<AnomalyFunctionDTO> anomalyFunctionDTOs = anomalyFunctionDAO.findAll();
    for (AnomalyFunctionDTO anomalyFunctionDTO : anomalyFunctionDTOs) {
        anomalyFunctionDTO.setActive(false);
        anomalyFunctionDAO.update(anomalyFunctionDTO);
    }
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Example 32 with AnomalyFunctionDTO

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

the class RunAdhocDatabaseQueriesTool method toggleAnomalyFunction.

private void toggleAnomalyFunction(Long id) {
    AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(id);
    anomalyFunction.setActive(true);
    anomalyFunctionDAO.update(anomalyFunction);
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Example 33 with AnomalyFunctionDTO

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

the class RunAdhocDatabaseQueriesTool method setAlertFilterForFunctionInCollection.

private void setAlertFilterForFunctionInCollection(String collection, List<String> metricList, Map<String, Map<String, String>> metricRuleMap, Map<String, String> defaultAlertFilter) {
    List<AnomalyFunctionDTO> anomalyFunctionDTOs = anomalyFunctionDAO.findAllByCollection(collection);
    for (AnomalyFunctionDTO anomalyFunctionDTO : anomalyFunctionDTOs) {
        String topicMetricName = anomalyFunctionDTO.getTopicMetric();
        if (metricList.contains(topicMetricName)) {
            Map<String, String> alertFilter = defaultAlertFilter;
            if (metricRuleMap.containsKey(topicMetricName)) {
                alertFilter = metricRuleMap.get(topicMetricName);
            }
            anomalyFunctionDTO.setAlertFilter(alertFilter);
            anomalyFunctionDAO.update(anomalyFunctionDTO);
            LOG.info("Add alert filter {} to function {} (dataset: {}, topic metric: {})", alertFilter, anomalyFunctionDTO.getId(), collection, topicMetricName);
        }
    }
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO)

Example 34 with AnomalyFunctionDTO

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

the class CleanupAndRegenerateAnomaliesTool method deleteExistingAnomalies.

/**
   * Delete raw or merged anomalies whose start time is located in the given time ranges, except
   * the following two cases:
   *
   * 1. If a raw anomaly belongs to a merged anomaly whose start time is not located in the given
   * time ranges, then the raw anomaly will not be deleted.
   *
   * 2. If a raw anomaly belongs to a merged anomaly whose start time is located in the given
   * time ranges, then it is deleted regardless its start time.
   *
   * If monitoringWindowStartTime is not given, then start time is set to 0.
   * If monitoringWindowEndTime is not given, then end time is set to Long.MAX_VALUE.
   */
private void deleteExistingAnomalies() {
    long startTime = 0;
    long endTime = Long.MAX_VALUE;
    if (StringUtils.isNotBlank(monitoringWindowStartTime)) {
        startTime = ISODateTimeFormat.dateTimeParser().parseDateTime(monitoringWindowStartTime).getMillis();
    }
    if (StringUtils.isNotBlank(monitoringWindowEndTime)) {
        endTime = ISODateTimeFormat.dateTimeParser().parseDateTime(monitoringWindowEndTime).getMillis();
    }
    LOG.info("Deleting anomalies in the time range: {} -- {}", new DateTime(startTime), new DateTime(endTime));
    for (Long functionId : functionIds) {
        AnomalyFunctionDTO anomalyFunction = anomalyFunctionDAO.findById(functionId);
        if (anomalyFunction == null) {
            LOG.info("Requested functionId {} doesn't exist", functionId);
            continue;
        }
        LOG.info("Beginning cleanup of functionId {} collection {} metric {}", functionId, anomalyFunction.getCollection(), anomalyFunction.getMetric());
        // Clean up merged and raw anomaly of functionID
        OnboardResource onboardResource = new OnboardResource(anomalyFunctionDAO, mergedResultDAO, rawResultDAO);
        onboardResource.deleteExistingAnomalies(Long.toString(functionId), startTime, endTime);
    }
}
Also used : OnboardResource(com.linkedin.thirdeye.dashboard.resources.OnboardResource) AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) DateTime(org.joda.time.DateTime)

Example 35 with AnomalyFunctionDTO

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

the class TestAlertFilterFactory method testFromAnomalyFunctionSpecToAlertFilter.

@Test
public void testFromAnomalyFunctionSpecToAlertFilter() throws Exception {
    AnomalyFunctionDTO anomalyFunctionSpec = getTestFunctionSpec(metricName, collection);
    AlertFilter alertFilter = alertFilterFactory.fromSpec(anomalyFunctionSpec.getAlertFilter());
    Assert.assertEquals(alertFilter.getClass(), DummyAlertFilter.class);
    anomalyFunctionSpec = getTestFunctionAlphaBetaAlertFilterSpec(metricName, collection);
    alertFilter = alertFilterFactory.fromSpec(anomalyFunctionSpec.getAlertFilter());
    Assert.assertEquals(alertFilter.getClass(), AlphaBetaAlertFilter.class);
}
Also used : AnomalyFunctionDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFunctionDTO) Test(org.testng.annotations.Test)

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