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