org.apache.kylin.rest.response.MetricsResponse Java Examples

The following examples show how to use org.apache.kylin.rest.response.MetricsResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CubeService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
public MetricsResponse calculateMetrics(MetricsRequest request) {
    List<CubeInstance> cubes = this.getCubeManager().listAllCubes();
    MetricsResponse metrics = new MetricsResponse();
    Date startTime = (null == request.getStartTime()) ? new Date(-1) : request.getStartTime();
    Date endTime = (null == request.getEndTime()) ? new Date() : request.getEndTime();
    metrics.increase("totalCubes", (float) 0);
    metrics.increase("totalStorage", (float) 0);

    for (CubeInstance cube : cubes) {
        Date createdDate = new Date(-1);
        createdDate = (cube.getCreateTimeUTC() == 0) ? createdDate : new Date(cube.getCreateTimeUTC());

        if (createdDate.getTime() > startTime.getTime() && createdDate.getTime() < endTime.getTime()) {
            metrics.increase("totalCubes");
        }
    }

    metrics.increase("aveStorage", (metrics.get("totalCubes") == 0) ? 0 : metrics.get("totalStorage") / metrics.get("totalCubes"));

    return metrics;
}
 
Example #2
Source File: DashboardController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/metric/query", method = RequestMethod.GET)
@ResponseBody
public MetricsResponse getQueryMetrics(@RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName,
        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
    checkAuthorization(projectName);
    MetricsResponse queryMetrics = new MetricsResponse();
    PrepareSqlRequest sqlRequest = dashboardService.getQueryMetricsSQLRequest(startTime, endTime, projectName,
            cubeName);
    SQLResponse sqlResponse = queryService.doQueryWithCache(sqlRequest);
    if (!sqlResponse.getIsException()) {
        queryMetrics.increase("queryCount",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(0)));
        queryMetrics.increase("avgQueryLatency",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(1)));
        queryMetrics.increase("maxQueryLatency",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(2)));
        queryMetrics.increase("minQueryLatency",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(3)));
    }
    return queryMetrics;
}
 
Example #3
Source File: DashboardController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/metric/job", method = RequestMethod.GET)
@ResponseBody
public MetricsResponse getJobMetrics(@RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName,
        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
    checkAuthorization(projectName);
    MetricsResponse jobMetrics = new MetricsResponse();
    PrepareSqlRequest sqlRequest = dashboardService.getJobMetricsSQLRequest(startTime, endTime, projectName,
            cubeName);
    SQLResponse sqlResponse = queryService.doQueryWithCache(sqlRequest);
    if (!sqlResponse.getIsException()) {
        jobMetrics.increase("jobCount", dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(0)));
        jobMetrics.increase("avgJobBuildTime",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(1)));
        jobMetrics.increase("maxJobBuildTime",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(2)));
        jobMetrics.increase("minJobBuildTime",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(3)));
    }
    return jobMetrics;
}
 
Example #4
Source File: CubeService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public MetricsResponse calculateMetrics(MetricsRequest request) {
    List<CubeInstance> cubes = this.getCubeManager().listAllCubes();
    MetricsResponse metrics = new MetricsResponse();
    Date startTime = (null == request.getStartTime()) ? new Date(-1) : request.getStartTime();
    Date endTime = (null == request.getEndTime()) ? new Date() : request.getEndTime();
    metrics.increase("totalCubes", (float) 0);
    metrics.increase("totalStorage", (float) 0);

    for (CubeInstance cube : cubes) {
        Date createdDate = new Date(-1);
        createdDate = (cube.getCreateTimeUTC() == 0) ? createdDate : new Date(cube.getCreateTimeUTC());

        if (createdDate.getTime() > startTime.getTime() && createdDate.getTime() < endTime.getTime()) {
            metrics.increase("totalCubes");
        }
    }

    metrics.increase("aveStorage",
            (metrics.get("totalCubes") == 0) ? 0 : metrics.get("totalStorage") / metrics.get("totalCubes"));

    return metrics;
}
 
Example #5
Source File: CubeService.java    From kylin with Apache License 2.0 6 votes vote down vote up
public MetricsResponse calculateMetrics(MetricsRequest request) {
    List<CubeInstance> cubes = this.getCubeManager().listAllCubes();
    MetricsResponse metrics = new MetricsResponse();
    Date startTime = (null == request.getStartTime()) ? new Date(-1) : request.getStartTime();
    Date endTime = (null == request.getEndTime()) ? new Date() : request.getEndTime();
    metrics.increase("totalCubes", (float) 0);
    metrics.increase("totalStorage", (float) 0);

    for (CubeInstance cube : cubes) {
        Date createdDate = new Date(-1);
        createdDate = (cube.getCreateTimeUTC() == 0) ? createdDate : new Date(cube.getCreateTimeUTC());

        if (createdDate.getTime() > startTime.getTime() && createdDate.getTime() < endTime.getTime()) {
            metrics.increase("totalCubes");
        }
    }

    metrics.increase("aveStorage",
            (metrics.get("totalCubes") == 0) ? 0 : metrics.get("totalStorage") / metrics.get("totalCubes"));

    return metrics;
}
 
Example #6
Source File: DashboardController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/metric/job", method = RequestMethod.GET)
@ResponseBody
public MetricsResponse getJobMetrics(@RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName,
        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
    checkAuthorization(projectName);
    MetricsResponse jobMetrics = new MetricsResponse();
    PrepareSqlRequest sqlRequest = dashboardService.getJobMetricsSQLRequest(startTime, endTime, projectName,
            cubeName);
    SQLResponse sqlResponse = queryService.doQueryWithCache(sqlRequest);
    if (!sqlResponse.getIsException()) {
        jobMetrics.increase("jobCount", dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(0)));
        jobMetrics.increase("avgJobBuildTime",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(1)));
        jobMetrics.increase("maxJobBuildTime",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(2)));
        jobMetrics.increase("minJobBuildTime",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(3)));
    }
    return jobMetrics;
}
 
Example #7
Source File: DashboardController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/metric/query", method = RequestMethod.GET)
@ResponseBody
public MetricsResponse getQueryMetrics(@RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName,
        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
    checkAuthorization(projectName);
    MetricsResponse queryMetrics = new MetricsResponse();
    PrepareSqlRequest sqlRequest = dashboardService.getQueryMetricsSQLRequest(startTime, endTime, projectName,
            cubeName);
    SQLResponse sqlResponse = queryService.doQueryWithCache(sqlRequest);
    if (!sqlResponse.getIsException()) {
        queryMetrics.increase("queryCount",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(0)));
        queryMetrics.increase("avgQueryLatency",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(1)));
        queryMetrics.increase("maxQueryLatency",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(2)));
        queryMetrics.increase("minQueryLatency",
                dashboardService.getMetricValue(sqlResponse.getResults().get(0).get(3)));
    }
    return queryMetrics;
}
 
Example #8
Source File: DashboardController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/metric/cube", method = { RequestMethod.GET })
@ResponseBody
public MetricsResponse getCubeMetrics(@RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName) {
    checkAuthorization(projectName);
    return dashboardService.getCubeMetrics(projectName, cubeName);
}
 
Example #9
Source File: DashboardService.java    From kylin with Apache License 2.0 5 votes vote down vote up
public MetricsResponse transformChartData(SQLResponse sqlResponse) {
    if (!sqlResponse.getIsException()) {
        MetricsResponse metrics = new MetricsResponse();
        List<List<String>> results = sqlResponse.getResults();
        for (List<String> result : results) {
            String dimension = result.get(0);
            if (dimension != null && !dimension.isEmpty()) {
                String metric = result.get(1);
                metrics.increase(dimension, getMetricValue(metric));
            }
        }
        return metrics;
    }
    return null;
}
 
Example #10
Source File: DashboardService.java    From kylin with Apache License 2.0 5 votes vote down vote up
public MetricsResponse getCubeMetrics(String projectName, String cubeName) {
    MetricsResponse cubeMetrics = new MetricsResponse();
    Float totalCubeSize = 0f;
    long totalRecoadSize = 0;
    List<CubeInstance> cubeInstances = cubeService.listAllCubes(cubeName, projectName, null, true);
    Integer totalCube = cubeInstances.size();
    if (projectName == null) {
        totalCube += getHybridManager().listHybridInstances().size();
    } else {
        ProjectInstance project = getProjectManager().getProject(projectName);
        totalCube += project.getRealizationCount(RealizationType.HYBRID);
    }
    Float minCubeExpansion = Float.POSITIVE_INFINITY;
    Float maxCubeExpansion = Float.NEGATIVE_INFINITY;
    cubeMetrics.increase("totalCube", totalCube.floatValue());
    for (CubeInstance cubeInstance : cubeInstances) {
        if (cubeInstance.getInputRecordSizeBytes() > 0) {
            totalCubeSize += cubeInstance.getSizeKB();
            totalRecoadSize += cubeInstance.getInputRecordSizeBytes();
            Float cubeExpansion = new Float(cubeInstance.getSizeKB()) * 1024
                    / cubeInstance.getInputRecordSizeBytes();
            if (cubeExpansion > maxCubeExpansion) {
                maxCubeExpansion = cubeExpansion;
            }
            if (cubeExpansion < minCubeExpansion) {
                minCubeExpansion = cubeExpansion;
            }
        }
    }
    Float avgCubeExpansion = 0f;
    if (totalRecoadSize != 0) {
        avgCubeExpansion = totalCubeSize * 1024 / totalRecoadSize;
    }
    cubeMetrics.increase("avgCubeExpansion", avgCubeExpansion);
    cubeMetrics.increase("maxCubeExpansion", maxCubeExpansion == Float.NEGATIVE_INFINITY ? 0 : maxCubeExpansion);
    cubeMetrics.increase("minCubeExpansion", minCubeExpansion == Float.POSITIVE_INFINITY ? 0 : minCubeExpansion);
    return cubeMetrics;
}
 
Example #11
Source File: DashboardController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/chart/{category}/{metric}/{dimension}", method = RequestMethod.GET)
@ResponseBody
public MetricsResponse getChartData(@PathVariable String dimension, @PathVariable String metric,
        @PathVariable String category, @RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName,
        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
    checkAuthorization(projectName);
    PrepareSqlRequest sqlRequest = dashboardService.getChartSQLRequest(startTime, endTime, projectName, cubeName,
            dimension, metric, category);
    return dashboardService.transformChartData(queryService.doQueryWithCache(sqlRequest));
}
 
Example #12
Source File: DashboardService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public MetricsResponse transformChartData(SQLResponse sqlResponse) {
    if (!sqlResponse.getIsException()) {
        MetricsResponse metrics = new MetricsResponse();
        List<List<String>> results = sqlResponse.getResults();
        for (List<String> result : results) {
            String dimension = result.get(0);
            if (dimension != null && !dimension.isEmpty()) {
                String metric = result.get(1);
                metrics.increase(dimension, getMetricValue(metric));
            }
        }
        return metrics;
    }
    return null;
}
 
Example #13
Source File: DashboardService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public MetricsResponse getCubeMetrics(String projectName, String cubeName) {
    MetricsResponse cubeMetrics = new MetricsResponse();
    Float totalCubeSize = 0f;
    long totalRecoadSize = 0;
    List<CubeInstance> cubeInstances = cubeService.listAllCubes(cubeName, projectName, null, true);
    Integer totalCube = cubeInstances.size();
    if (projectName == null) {
        totalCube += getHybridManager().listHybridInstances().size();
    } else {
        ProjectInstance project = getProjectManager().getProject(projectName);
        totalCube += project.getRealizationCount(RealizationType.HYBRID);
    }
    Float minCubeExpansion = Float.POSITIVE_INFINITY;
    Float maxCubeExpansion = Float.NEGATIVE_INFINITY;
    cubeMetrics.increase("totalCube", totalCube.floatValue());
    for (CubeInstance cubeInstance : cubeInstances) {
        if (cubeInstance.getInputRecordSizeBytes() > 0) {
            totalCubeSize += cubeInstance.getSizeKB();
            totalRecoadSize += cubeInstance.getInputRecordSizeBytes();
            Float cubeExpansion = new Float(cubeInstance.getSizeKB()) * 1024
                    / cubeInstance.getInputRecordSizeBytes();
            if (cubeExpansion > maxCubeExpansion) {
                maxCubeExpansion = cubeExpansion;
            }
            if (cubeExpansion < minCubeExpansion) {
                minCubeExpansion = cubeExpansion;
            }
        }
    }
    Float avgCubeExpansion = 0f;
    if (totalRecoadSize != 0) {
        avgCubeExpansion = totalCubeSize * 1024 / totalRecoadSize;
    }
    cubeMetrics.increase("avgCubeExpansion", avgCubeExpansion);
    cubeMetrics.increase("maxCubeExpansion", maxCubeExpansion == Float.NEGATIVE_INFINITY ? 0 : maxCubeExpansion);
    cubeMetrics.increase("minCubeExpansion", minCubeExpansion == Float.POSITIVE_INFINITY ? 0 : minCubeExpansion);
    return cubeMetrics;
}
 
Example #14
Source File: DashboardController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/chart/{category}/{metric}/{dimension}", method = RequestMethod.GET)
@ResponseBody
public MetricsResponse getChartData(@PathVariable String dimension, @PathVariable String metric,
        @PathVariable String category, @RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName,
        @RequestParam(value = "startTime") String startTime, @RequestParam(value = "endTime") String endTime) {
    checkAuthorization(projectName);
    PrepareSqlRequest sqlRequest = dashboardService.getChartSQLRequest(startTime, endTime, projectName, cubeName,
            dimension, metric, category);
    return dashboardService.transformChartData(queryService.doQueryWithCache(sqlRequest));
}
 
Example #15
Source File: DashboardController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/metric/cube", method = { RequestMethod.GET })
@ResponseBody
public MetricsResponse getCubeMetrics(@RequestParam(value = "projectName", required = false) String projectName,
        @RequestParam(value = "cubeName", required = false) String cubeName) {
    checkAuthorization(projectName);
    return dashboardService.getCubeMetrics(projectName, cubeName);
}
 
Example #16
Source File: AdminController.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/metrics/cubes", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public MetricsResponse cubeMetrics(MetricsRequest request) {
    return cubeMgmtService.calculateMetrics(request);
}
 
Example #17
Source File: AdminController.java    From kylin with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/metrics/cubes", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public MetricsResponse cubeMetrics(MetricsRequest request) {
    return cubeMgmtService.calculateMetrics(request);
}
 
Example #18
Source File: AdminController.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@RequestMapping(value = "/metrics/cubes", method = { RequestMethod.GET })
@ResponseBody
public MetricsResponse cubeMetrics(MetricsRequest request) {
    return cubeMgmtService.calculateMetrics(request);
}