Search in sources :

Example 51 with MetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.

the class TimeSeriesResource method getTimeseriesCompareData.

@GET
@Path("/compare/{metricId}/{currentStart}/{currentEnd}/{baselineStart}/{baselineEnd}")
public TimeSeriesCompareMetricView getTimeseriesCompareData(@PathParam("metricId") long metricId, @PathParam("currentStart") long currentStart, @PathParam("currentEnd") long currentEnd, @PathParam("baselineStart") long baselineStart, @PathParam("baselineEnd") long baselineEnd, @QueryParam("dimension") String dimension, @QueryParam("filters") String filters, @QueryParam("granularity") String granularity, // Auto Resize tries to limit the number of data points to 20
@DefaultValue("false") @QueryParam("limitDataPointNum") boolean limitDataPointNum, @DefaultValue("20") @QueryParam("dataPointNum") int dataPointNum) {
    try {
        if (Strings.isNullOrEmpty(dimension)) {
            dimension = ALL;
        }
        MetricConfigDTO metricConfigDTO = metricConfigDAO.findById(metricId);
        String dataset = metricConfigDTO.getDataset();
        long maxDataTime = datasetMaxDataTimeCache.get(dataset);
        if (currentEnd > maxDataTime) {
            long delta = currentEnd - maxDataTime;
            currentEnd = currentEnd - delta;
            baselineEnd = baselineStart + (currentEnd - currentStart);
        }
        long analysisDuration = currentEnd - currentStart;
        if (baselineEnd - baselineStart != analysisDuration) {
            baselineEnd = baselineStart + analysisDuration;
        }
        if (baselineEnd > currentEnd) {
            LOG.warn("Baseline time ranges are out of order, resetting as per current time ranges.");
            baselineEnd = currentEnd - TimeUnit.DAYS.toMillis(7);
            baselineStart = currentStart - TimeUnit.DAYS.toMillis(7);
        }
        if (StringUtils.isEmpty(granularity)) {
            granularity = "DAYS";
        }
        if (limitDataPointNum) {
            granularity = Utils.resizeTimeGranularity(analysisDuration, granularity, dataPointNum);
        }
        if (dimension.equalsIgnoreCase(ALL)) {
            return getTabularData(metricId, currentStart, currentEnd, baselineStart, baselineEnd, filters, granularity);
        } else {
            // build contributor view request
            return getContributorDataForDimension(metricId, currentStart, currentEnd, baselineStart, baselineEnd, dimension, filters, granularity);
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new WebApplicationException(e);
    }
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) WebApplicationException(javax.ws.rs.WebApplicationException) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 52 with MetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.

the class MetricConfigManagerImpl method findWhereNameLike.

@Override
public List<MetricConfigDTO> findWhereNameLike(String name) {
    Map<String, Object> parameterMap = new HashMap<>();
    parameterMap.put("name", name);
    List<MetricConfigBean> list = genericPojoDao.executeParameterizedSQL(FIND_BY_NAME_LIKE, parameterMap, MetricConfigBean.class);
    List<MetricConfigDTO> result = new ArrayList<>();
    for (MetricConfigBean bean : list) {
        result.add(MODEL_MAPPER.map(bean, MetricConfigDTO.class));
    }
    return result;
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) MetricConfigBean(com.linkedin.thirdeye.datalayer.pojo.MetricConfigBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 53 with MetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.

the class MetricConfigManagerImpl method findActiveByDataset.

@Override
public List<MetricConfigDTO> findActiveByDataset(String dataset) {
    Predicate datasetPredicate = Predicate.EQ("dataset", dataset);
    Predicate activePredicate = Predicate.EQ("active", true);
    List<MetricConfigBean> list = genericPojoDao.get(Predicate.AND(datasetPredicate, activePredicate), MetricConfigBean.class);
    List<MetricConfigDTO> result = new ArrayList<>();
    for (MetricConfigBean abstractBean : list) {
        MetricConfigDTO dto = MODEL_MAPPER.map(abstractBean, MetricConfigDTO.class);
        result.add(dto);
    }
    return result;
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) MetricConfigBean(com.linkedin.thirdeye.datalayer.pojo.MetricConfigBean) ArrayList(java.util.ArrayList) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 54 with MetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO in project pinot by linkedin.

the class MetricConfigManagerImpl method findByDataset.

@Override
public List<MetricConfigDTO> findByDataset(String dataset) {
    Predicate predicate = Predicate.EQ("dataset", dataset);
    List<MetricConfigBean> list = genericPojoDao.get(predicate, MetricConfigBean.class);
    List<MetricConfigDTO> result = new ArrayList<>();
    for (MetricConfigBean abstractBean : list) {
        MetricConfigDTO dto = MODEL_MAPPER.map(abstractBean, MetricConfigDTO.class);
        result.add(dto);
    }
    return result;
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) MetricConfigBean(com.linkedin.thirdeye.datalayer.pojo.MetricConfigBean) ArrayList(java.util.ArrayList) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Aggregations

MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)54 ArrayList (java.util.ArrayList)22 Path (javax.ws.rs.Path)18 GET (javax.ws.rs.GET)17 HashMap (java.util.HashMap)13 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)9 DashboardConfigDTO (com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)8 WebApplicationException (javax.ws.rs.WebApplicationException)8 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)7 MetricDataset (com.linkedin.thirdeye.client.cache.MetricDataset)7 DateTime (org.joda.time.DateTime)7 DateTimeZone (org.joda.time.DateTimeZone)7 MetricConfigBean (com.linkedin.thirdeye.datalayer.pojo.MetricConfigBean)6 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)5 IOException (java.io.IOException)5 LinkedHashMap (java.util.LinkedHashMap)5 Test (org.testng.annotations.Test)5 MetricFieldSpec (com.linkedin.pinot.common.data.MetricFieldSpec)4 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)4 ExecutionException (java.util.concurrent.ExecutionException)4