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);
}
}
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);
}
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);
}
}
}
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);
}
}
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);
}
Aggregations