use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class AutoloadPinotMetricsServiceTest method testRefreshDataset.
@Test(dependsOnMethods = { "testAddNewDataset" })
public void testRefreshDataset() throws Exception {
DimensionFieldSpec dimensionFieldSpec = new DimensionFieldSpec("newDimension", DataType.STRING, true);
schema.addField(dimensionFieldSpec);
testAutoLoadPinotMetricsService.addPinotDataset(dataset, schema, datasetConfig);
Assert.assertEquals(datasetConfigDAO.findAll().size(), 1);
DatasetConfigDTO newDatasetConfig1 = datasetConfigDAO.findByDataset(dataset);
Assert.assertEquals(newDatasetConfig1.getDataset(), dataset);
Assert.assertEquals(Sets.newHashSet(newDatasetConfig1.getDimensions()), Sets.newHashSet(schema.getDimensionNames()));
MetricFieldSpec metricFieldSpec = new MetricFieldSpec("newMetric", DataType.LONG);
schema.addField(metricFieldSpec);
testAutoLoadPinotMetricsService.addPinotDataset(dataset, schema, newDatasetConfig1);
Assert.assertEquals(datasetConfigDAO.findAll().size(), 1);
List<MetricConfigDTO> metricConfigs = metricConfigDAO.findByDataset(dataset);
List<String> schemaMetricNames = schema.getMetricNames();
List<Long> metricIds = new ArrayList<>();
Assert.assertEquals(metricConfigs.size(), schemaMetricNames.size());
for (MetricConfigDTO metricConfig : metricConfigs) {
Assert.assertTrue(schemaMetricNames.contains(metricConfig.getName()));
metricIds.add(metricConfig.getId());
}
DashboardConfigDTO dashboardConfig = dashboardConfigDAO.findByName(DashboardConfigBean.DEFAULT_DASHBOARD_PREFIX + dataset);
Assert.assertEquals(dashboardConfig.getMetricIds(), metricIds);
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class ThirdEyeUtils method substituteMetricIdsForMetrics.
// TODO: Write parser instead of looking for occurrence of every metric
public static String substituteMetricIdsForMetrics(String metricExpression, String dataset) {
MetricConfigManager metricConfigDAO = DAO_REGISTRY.getMetricConfigDAO();
List<MetricConfigDTO> metricConfigs = metricConfigDAO.findByDataset(dataset);
for (MetricConfigDTO metricConfig : metricConfigs) {
if (metricConfig.isDerived()) {
continue;
}
String metricName = metricConfig.getName();
metricExpression = metricExpression.replaceAll(metricName, MetricConfigBean.DERIVED_METRIC_ID_PREFIX + metricConfig.getId());
}
return metricExpression;
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class ThirdEyeUtils method getMetricThresholdsMap.
public static Map<String, Double> getMetricThresholdsMap(List<MetricFunction> metricFunctions) {
Map<String, Double> metricThresholds = new HashMap<>();
for (MetricFunction metricFunction : metricFunctions) {
String derivedMetricExpression = metricFunction.getMetricName();
String metricId = derivedMetricExpression.replaceAll(MetricConfigBean.DERIVED_METRIC_ID_PREFIX, "");
MetricConfigDTO metricConfig = DAO_REGISTRY.getMetricConfigDAO().findById(Long.valueOf(metricId));
metricThresholds.put(derivedMetricExpression, metricConfig.getRollupThreshold());
}
return metricThresholds;
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class AnomaliesResource method getExternalURL.
private String getExternalURL(MergedAnomalyResultDTO mergedAnomaly) {
String metric = mergedAnomaly.getMetric();
String dataset = mergedAnomaly.getCollection();
Long startTime = mergedAnomaly.getStartTime();
Long endTime = mergedAnomaly.getEndTime();
MetricConfigDTO metricConfigDTO = metricConfigDAO.findByMetricAndDataset(metric, dataset);
Map<String, String> context = new HashMap<>();
context.put(MetricConfigBean.URL_TEMPLATE_START_TIME, String.valueOf(startTime));
context.put(MetricConfigBean.URL_TEMPLATE_END_TIME, String.valueOf(endTime));
StrSubstitutor strSubstitutor = new StrSubstitutor(context);
Map<String, String> urlTemplates = metricConfigDTO.getExtSourceLinkInfo();
if (urlTemplates == null) {
return "";
}
for (Map.Entry<String, String> entry : urlTemplates.entrySet()) {
String sourceName = entry.getKey();
String urlTemplate = entry.getValue();
String extSourceUrl = strSubstitutor.replace(urlTemplate);
urlTemplates.put(sourceName, extSourceUrl);
}
return new JSONObject(urlTemplates).toString();
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class DataResource method getDataAggregationGranularity.
@GET
@Path("agg/granularity/metric/{metricId}")
public List<String> getDataAggregationGranularity(@PathParam("metricId") Long metricId) {
List<String> list = new ArrayList<>();
list.add("DAYS");
MetricConfigDTO metricConfigDTO = metricConfigDAO.findById(metricId);
DatasetConfigDTO datasetConfigDTO = datasetConfigDAO.findByDataset(metricConfigDTO.getDataset());
int dataAggSize = datasetConfigDTO.getTimeDuration();
String dataGranularity = datasetConfigDTO.getTimeUnit().name();
if (dataGranularity.equals("DAYS")) {
// do nothing
} else {
list.add("HOURS");
if (dataGranularity.equals("MINUTES")) {
if (dataAggSize == 1) {
list.add("MINUTES");
} else {
list.add(dataAggSize + "_MINUTES");
}
}
}
return list;
}
Aggregations