use of com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO in project pinot by linkedin.
the class EntityManagerResource method updateEntity.
@POST
public Response updateEntity(@QueryParam("entityType") String entityTypeStr, String jsonPayload) {
if (Strings.isNullOrEmpty(entityTypeStr)) {
throw new WebApplicationException("EntryType can not be null");
}
EntityType entityType = EntityType.valueOf(entityTypeStr);
try {
switch(entityType) {
case ANOMALY_FUNCTION:
AnomalyFunctionDTO anomalyFunctionDTO = OBJECT_MAPPER.readValue(jsonPayload, AnomalyFunctionDTO.class);
if (anomalyFunctionDTO.getId() == null) {
anomalyFunctionManager.save(anomalyFunctionDTO);
} else {
anomalyFunctionManager.update(anomalyFunctionDTO);
}
break;
case EMAIL_CONFIGURATION:
EmailConfigurationDTO emailConfigurationDTO = OBJECT_MAPPER.readValue(jsonPayload, EmailConfigurationDTO.class);
emailConfigurationManager.update(emailConfigurationDTO);
break;
case DASHBOARD_CONFIG:
DashboardConfigDTO dashboardConfigDTO = OBJECT_MAPPER.readValue(jsonPayload, DashboardConfigDTO.class);
dashboardConfigManager.update(dashboardConfigDTO);
break;
case DATASET_CONFIG:
DatasetConfigDTO datasetConfigDTO = OBJECT_MAPPER.readValue(jsonPayload, DatasetConfigDTO.class);
datasetConfigManager.update(datasetConfigDTO);
break;
case METRIC_CONFIG:
MetricConfigDTO metricConfigDTO = OBJECT_MAPPER.readValue(jsonPayload, MetricConfigDTO.class);
metricConfigManager.update(metricConfigDTO);
break;
case OVERRIDE_CONFIG:
OverrideConfigDTO overrideConfigDTO = OBJECT_MAPPER.readValue(jsonPayload, OverrideConfigDTO.class);
if (overrideConfigDTO.getId() == null) {
overrideConfigManager.save(overrideConfigDTO);
} else {
overrideConfigManager.update(overrideConfigDTO);
}
break;
case ALERT_CONFIG:
AlertConfigDTO alertConfigDTO = OBJECT_MAPPER.readValue(jsonPayload, AlertConfigDTO.class);
if (alertConfigDTO.getId() == null) {
alertConfigManager.save(alertConfigDTO);
} else {
alertConfigManager.update(alertConfigDTO);
}
break;
}
} catch (IOException e) {
LOG.error("Error saving the entity with payload : " + jsonPayload, e);
throw new WebApplicationException(e);
}
return Response.ok().build();
}
use of com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO in project pinot by linkedin.
the class AnomaliesResource method getAnomalyDataCompareResults.
@GET
@Path("/{anomalyId}")
public AnomalyDataCompare.Response getAnomalyDataCompareResults(@PathParam("anomalyId") Long anomalyId) {
MergedAnomalyResultDTO anomaly = mergedAnomalyResultDAO.findById(anomalyId);
if (anomaly == null) {
LOG.error("Anomaly not found with id " + anomalyId);
throw new IllegalArgumentException("Anomaly not found with id " + anomalyId);
}
AnomalyDataCompare.Response response = new AnomalyDataCompare.Response();
response.setCurrentStart(anomaly.getStartTime());
response.setCurrenEnd(anomaly.getEndTime());
try {
DatasetConfigDTO dataset = datasetConfigDAO.findByDataset(anomaly.getCollection());
TimeGranularity granularity = new TimeGranularity(dataset.getTimeDuration(), dataset.getTimeUnit());
// Lets compute currentTimeRange
Pair<Long, Long> currentTmeRange = new Pair<>(anomaly.getStartTime(), anomaly.getEndTime());
MetricTimeSeries ts = TimeSeriesUtil.getTimeSeriesByDimension(anomaly.getFunction(), Arrays.asList(currentTmeRange), anomaly.getDimensions(), granularity, false);
double currentVal = getTotalFromTimeSeries(ts, dataset.isAdditive());
response.setCurrentVal(currentVal);
for (AlertConfigBean.COMPARE_MODE compareMode : AlertConfigBean.COMPARE_MODE.values()) {
long baselineOffset = EmailHelper.getBaselineOffset(compareMode);
Pair<Long, Long> baselineTmeRange = new Pair<>(anomaly.getStartTime() - baselineOffset, anomaly.getEndTime() - baselineOffset);
MetricTimeSeries baselineTs = TimeSeriesUtil.getTimeSeriesByDimension(anomaly.getFunction(), Arrays.asList(baselineTmeRange), anomaly.getDimensions(), granularity, false);
AnomalyDataCompare.CompareResult cr = new AnomalyDataCompare.CompareResult();
double baseLineval = getTotalFromTimeSeries(baselineTs, dataset.isAdditive());
cr.setBaselineValue(baseLineval);
cr.setCompareMode(compareMode);
cr.setChange(calculateChange(currentVal, baseLineval));
response.getCompareResults().add(cr);
}
} catch (Exception e) {
LOG.error("Error fetching the timeseries data from pinot", e);
throw new RuntimeException(e);
}
return response;
}
use of com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO in project pinot by linkedin.
the class DataResource method getFiltersForMetric.
@GET
@Path("autocomplete/filters/metric/{metricId}")
public Map<String, List<String>> getFiltersForMetric(@PathParam("metricId") Long metricId) {
Map<String, List<String>> filterMap = new HashMap<>();
try {
// TODO : cache this
MetricConfigDTO metricConfigDTO = metricConfigDAO.findById(metricId);
DatasetConfigDTO datasetConfigDTO = datasetConfigDAO.findByDataset(metricConfigDTO.getDataset());
String dimensionFiltersJson = dimensionsFilterCache.get(datasetConfigDTO.getDataset());
if (!Strings.isNullOrEmpty(dimensionFiltersJson)) {
filterMap = OBJECT_MAPPER.readValue(dimensionFiltersJson, LinkedHashMap.class);
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new WebApplicationException(e);
}
return filterMap;
}
use of com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO in project pinot by linkedin.
the class DatasetConfigManagerImpl method findByDataset.
@Override
public DatasetConfigDTO findByDataset(String dataset) {
Predicate predicate = Predicate.EQ("dataset", dataset);
List<DatasetConfigBean> list = genericPojoDao.get(predicate, DatasetConfigBean.class);
DatasetConfigDTO result = null;
if (CollectionUtils.isNotEmpty(list)) {
result = MODEL_MAPPER.map(list.get(0), DatasetConfigDTO.class);
}
return result;
}
use of com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO in project pinot by linkedin.
the class TabularViewHandler method generateTimeOnTimeComparisonRequest.
private TimeOnTimeComparisonRequest generateTimeOnTimeComparisonRequest(TabularViewRequest request) throws Exception {
TimeOnTimeComparisonRequest comparisonRequest = new TimeOnTimeComparisonRequest();
String collection = request.getCollection();
DateTime baselineStart = request.getBaselineStart();
DateTime baselineEnd = request.getBaselineEnd();
DateTime currentStart = request.getCurrentStart();
DateTime currentEnd = request.getCurrentEnd();
DatasetConfigDTO datasetConfig = CACHE_REGISTRY.getDatasetConfigCache().get(collection);
TimeSpec timespec = ThirdEyeUtils.getTimeSpecFromDatasetConfig(datasetConfig);
if (!request.getTimeGranularity().getUnit().equals(TimeUnit.DAYS) || !StringUtils.isBlank(timespec.getFormat())) {
comparisonRequest.setEndDateInclusive(true);
}
Multimap<String, String> filters = request.getFilters();
List<MetricExpression> metricExpressions = request.getMetricExpressions();
comparisonRequest.setCollectionName(collection);
comparisonRequest.setBaselineStart(baselineStart);
comparisonRequest.setBaselineEnd(baselineEnd);
comparisonRequest.setCurrentStart(currentStart);
comparisonRequest.setCurrentEnd(currentEnd);
comparisonRequest.setFilterSet(filters);
comparisonRequest.setMetricExpressions(metricExpressions);
comparisonRequest.setAggregationTimeGranularity(request.getTimeGranularity());
return comparisonRequest;
}
Aggregations