use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class DashboardResource method getMaxTime.
@GET
@Path(value = "/data/info")
@Produces(MediaType.APPLICATION_JSON)
public String getMaxTime(@QueryParam("dataset") String collection) {
String collectionInfo = null;
try {
HashMap<String, String> map = new HashMap<>();
long maxDataTime = collectionMaxDataTimeCache.get(collection);
DatasetConfigDTO datasetConfig = CACHE_REGISTRY_INSTANCE.getDatasetConfigCache().get(collection);
TimeSpec timespec = ThirdEyeUtils.getTimeSpecFromDatasetConfig(datasetConfig);
TimeGranularity dataGranularity = timespec.getDataGranularity();
map.put("maxTime", "" + maxDataTime);
map.put("dataGranularity", dataGranularity.getUnit().toString());
List<MetricConfigDTO> metricConfigs = metricConfigDAO.findActiveByDataset(collection);
List<String> inverseMetrics = new ArrayList<>();
for (MetricConfigDTO metricConfig : metricConfigs) {
if (metricConfig.isInverseMetric()) {
inverseMetrics.add(metricConfig.getName());
}
}
if (CollectionUtils.isNotEmpty(inverseMetrics)) {
map.put("invertColorMetrics", Joiner.on(",").join(inverseMetrics));
}
collectionInfo = OBJECT_MAPPER.writeValueAsString(map);
} catch (Exception e) {
LOG.error("Error while fetching info for collection: " + collection, e);
}
return collectionInfo;
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class DashboardResource method getMetrics.
@GET
@Path(value = "/data/metrics")
@Produces(MediaType.APPLICATION_JSON)
public List<String> getMetrics(@QueryParam("dataset") String collection) throws Exception {
try {
List<String> metrics = new ArrayList<>();
List<MetricConfigDTO> metricConfigs = metricConfigDAO.findActiveByDataset(collection);
for (MetricConfigDTO metricConfig : metricConfigs) {
metrics.add(metricConfig.getName());
}
Collections.sort(metrics);
return metrics;
} catch (Exception e) {
LOG.error("Error while fetching metrics", e);
throw e;
}
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class MetricConfigResource method getMetricsForDataset.
@GET
@Path("/metrics")
public String getMetricsForDataset(@NotNull @QueryParam("dataset") String dataset) {
Map<String, Object> filters = new HashMap<>();
filters.put("dataset", dataset);
List<MetricConfigDTO> metricConfigDTOs = metricConfigDao.findByParams(filters);
List<String> metrics = new ArrayList<>();
for (MetricConfigDTO metricConfigDTO : metricConfigDTOs) {
metrics.add(metricConfigDTO.getAlias());
}
return JsonResponseUtil.buildResponseJSON(metrics).toString();
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class MetricConfigResource method viewMetricConfig.
@GET
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String viewMetricConfig(@NotNull @QueryParam("dataset") String dataset, @DefaultValue("0") @QueryParam("jtStartIndex") int jtStartIndex, @DefaultValue("100") @QueryParam("jtPageSize") int jtPageSize) {
Map<String, Object> filters = new HashMap<>();
filters.put("dataset", dataset);
List<MetricConfigDTO> metricConfigDTOs = metricConfigDao.findByParams(filters);
List<MetricConfigDTO> subList = Utils.sublist(metricConfigDTOs, jtStartIndex, jtPageSize);
ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(subList);
return rootNode.toString();
}
use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.
the class AutoloadPinotMetricsServiceTest method testAddNewDataset.
@Test
public void testAddNewDataset() throws Exception {
testAutoLoadPinotMetricsService = new AutoLoadPinotMetricsService();
schema = Schema.fromInputSteam(ClassLoader.getSystemResourceAsStream("sample-pinot-schema.json"));
testAutoLoadPinotMetricsService.addPinotDataset(dataset, schema, datasetConfig);
Assert.assertEquals(datasetConfigDAO.findAll().size(), 1);
datasetConfig = datasetConfigDAO.findByDataset(dataset);
Assert.assertEquals(datasetConfig.getDataset(), dataset);
Assert.assertEquals(datasetConfig.getDimensions(), schema.getDimensionNames());
Assert.assertEquals(datasetConfig.getTimeColumn(), schema.getTimeColumnName());
TimeGranularitySpec timeGranularitySpec = schema.getTimeFieldSpec().getOutgoingGranularitySpec();
Assert.assertEquals(datasetConfig.getTimeUnit(), timeGranularitySpec.getTimeType());
Assert.assertEquals(datasetConfig.getTimeDuration(), new Integer(timeGranularitySpec.getTimeUnitSize()));
Assert.assertEquals(datasetConfig.getTimeFormat(), timeGranularitySpec.getTimeFormat());
Assert.assertEquals(datasetConfig.getTimezone(), "UTC");
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);
}
Aggregations