Search in sources :

Example 6 with DashboardConfigDTO

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

the class MetricConfigResource method deleteMetricConfig.

@GET
@Path("/delete")
public String deleteMetricConfig(@NotNull @QueryParam("dataset") String dataset, @NotNull @QueryParam("id") Long metricConfigId) {
    metricConfigDao.deleteById(metricConfigId);
    DashboardConfigDTO dashboardConfigDTO = dashboardConfigDAO.findByName(ThirdEyeUtils.getDefaultDashboardName(dataset));
    if (dashboardConfigDTO != null) {
        List<Long> metricIds = dashboardConfigDTO.getMetricIds();
        metricIds.removeAll(Lists.newArrayList(metricConfigId));
        dashboardConfigDTO.setMetricIds(metricIds);
        dashboardConfigDAO.update(dashboardConfigDTO);
    }
    return JsonResponseUtil.buildSuccessResponseJSON("Successully deleted " + metricConfigId).toString();
}
Also used : DashboardConfigDTO(com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 7 with DashboardConfigDTO

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

the class DashboardResource method getDashboardData.

@GET
@Path(value = "/data/customDashboard")
@Produces(MediaType.APPLICATION_JSON)
public String getDashboardData(@QueryParam("dataset") String collection, @QueryParam("dashboard") String dashboardName, @QueryParam("filters") String filterJson, @QueryParam("timeZone") @DefaultValue(DEFAULT_TIMEZONE_ID) String timeZone, @QueryParam("baselineStart") Long baselineStart, @QueryParam("baselineEnd") Long baselineEnd, @QueryParam("currentStart") Long currentStart, @QueryParam("currentEnd") Long currentEnd, @QueryParam("compareMode") String compareMode, @QueryParam("aggTimeGranularity") String aggTimeGranularity) {
    try {
        TabularViewRequest request = new TabularViewRequest();
        request.setCollection(collection);
        List<MetricExpression> metricExpressions = new ArrayList<>();
        DashboardConfigDTO dashboardConfig = dashboardConfigDAO.findByName(dashboardName);
        List<Long> metricIds = dashboardConfig.getMetricIds();
        for (Long metricId : metricIds) {
            MetricConfigDTO metricConfig = metricConfigDAO.findById(metricId);
            MetricExpression metricExpression = ThirdEyeUtils.getMetricExpressionFromMetricConfig(metricConfig);
            metricExpressions.add(metricExpression);
        }
        request.setMetricExpressions(metricExpressions);
        long maxDataTime = collectionMaxDataTimeCache.get(collection);
        if (currentEnd > maxDataTime) {
            long delta = currentEnd - maxDataTime;
            currentEnd = currentEnd - delta;
            baselineEnd = baselineEnd - delta;
        }
        // The input start and end time (i.e., currentStart, currentEnd, baselineStart, and
        // baselineEnd) are given in millisecond since epoch, which is timezone insensitive. On the
        // other hand, the start and end time of the request to be sent to backend database (e.g.,
        // Pinot) could be converted to SimpleDateFormat, which is timezone sensitive. Therefore,
        // we need to store user's start and end time in DateTime objects with data's timezone
        // in order to ensure that the conversion to SimpleDateFormat is always correct regardless
        // user and server's timezone, including daylight saving time.
        DateTimeZone timeZoneForCollection = Utils.getDataTimeZone(collection);
        request.setBaselineStart(new DateTime(baselineStart, timeZoneForCollection));
        request.setBaselineEnd(new DateTime(baselineEnd, timeZoneForCollection));
        request.setCurrentStart(new DateTime(currentStart, timeZoneForCollection));
        request.setCurrentEnd(new DateTime(currentEnd, timeZoneForCollection));
        if (filterJson != null && !filterJson.isEmpty()) {
            filterJson = URLDecoder.decode(filterJson, "UTF-8");
            request.setFilters(ThirdEyeUtils.convertToMultiMap(filterJson));
        }
        request.setTimeGranularity(Utils.getAggregationTimeGranularity(aggTimeGranularity, collection));
        TabularViewHandler handler = new TabularViewHandler(queryCache);
        String jsonResponse = null;
        TabularViewResponse response = handler.process(request);
        jsonResponse = OBJECT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(response);
        LOG.debug("customDashboard response {}", jsonResponse);
        return jsonResponse;
    } catch (Exception e) {
        LOG.error("Exception while processing /data/tabular call", e);
        return "{\"ERROR\": + " + e.getMessage() + "}";
    }
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) TabularViewHandler(com.linkedin.thirdeye.dashboard.views.tabular.TabularViewHandler) ArrayList(java.util.ArrayList) TabularViewResponse(com.linkedin.thirdeye.dashboard.views.tabular.TabularViewResponse) MetricExpression(com.linkedin.thirdeye.client.MetricExpression) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime) JSONException(org.json.JSONException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) DashboardConfigDTO(com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO) TabularViewRequest(com.linkedin.thirdeye.dashboard.views.tabular.TabularViewRequest) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 8 with DashboardConfigDTO

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

the class DashboardConfigManagerImpl method findWhereNameLike.

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

Example 9 with DashboardConfigDTO

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

the class RunAdhocDatabaseQueriesTool method createDashboard.

private void createDashboard(String dataset) {
    String dashboardName = ThirdEyeUtils.getDefaultDashboardName(dataset);
    DashboardConfigDTO dashboardConfig = dashboardConfigDAO.findByName(dashboardName);
    dashboardConfig.setMetricIds(ConfigGenerator.getMetricIdsFromMetricConfigs(metricConfigDAO.findByDataset(dataset)));
    dashboardConfigDAO.update(dashboardConfig);
}
Also used : DashboardConfigDTO(com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)

Example 10 with DashboardConfigDTO

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

the class DataResource method getDashboardNames.

@GET
@Path("summary/dashboards")
public List<String> getDashboardNames() {
    List<String> output = new ArrayList<>();
    List<DashboardConfigDTO> dashboardConfigDTOs = dashboardConfigDAO.findAll();
    for (DashboardConfigDTO dashboardConfigDTO : dashboardConfigDTOs) {
        output.add(dashboardConfigDTO.getName());
    }
    return output;
}
Also used : ArrayList(java.util.ArrayList) DashboardConfigDTO(com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

DashboardConfigDTO (com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO)18 ArrayList (java.util.ArrayList)9 MetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO)8 MetricFieldSpec (com.linkedin.pinot.common.data.MetricFieldSpec)4 DatasetConfigDTO (com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO)4 DashboardConfigBean (com.linkedin.thirdeye.datalayer.pojo.DashboardConfigBean)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)3 IOException (java.io.IOException)2 Test (org.testng.annotations.Test)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 LoadingCache (com.google.common.cache.LoadingCache)1 RemovalListener (com.google.common.cache.RemovalListener)1 RemovalNotification (com.google.common.cache.RemovalNotification)1 ResultSetGroup (com.linkedin.pinot.client.ResultSetGroup)1 DimensionFieldSpec (com.linkedin.pinot.common.data.DimensionFieldSpec)1 FieldSpec (com.linkedin.pinot.common.data.FieldSpec)1 TimeGranularitySpec (com.linkedin.pinot.common.data.TimeGranularitySpec)1 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)1