Search in sources :

Example 96 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class AnomaliesResource method getAnomalyCountForMetricInRange.

/**
   * Get count of anomalies for metric in time range
   * @param metricId
   * @param startTime
   * @param endTime
   * @return
   */
@GET
@Path("getAnomalyCount/{metricId}/{startTime}/{endTime}")
public AnomaliesSummary getAnomalyCountForMetricInRange(@PathParam("metricId") Long metricId, @PathParam("startTime") Long startTime, @PathParam("endTime") Long endTime) {
    AnomaliesSummary anomaliesSummary = new AnomaliesSummary();
    List<MergedAnomalyResultDTO> mergedAnomalies = getAnomaliesForMetricIdInRange(metricId, startTime, endTime);
    int resolvedAnomalies = 0;
    int unresolvedAnomalies = 0;
    for (MergedAnomalyResultDTO mergedAnomaly : mergedAnomalies) {
        AnomalyFeedbackDTO anomalyFeedback = mergedAnomaly.getFeedback();
        if (anomalyFeedback == null || anomalyFeedback.getFeedbackType() == null) {
            unresolvedAnomalies++;
        } else if (anomalyFeedback != null && anomalyFeedback.getFeedbackType() != null && anomalyFeedback.getFeedbackType().equals(AnomalyFeedbackType.ANOMALY)) {
            unresolvedAnomalies++;
        } else {
            resolvedAnomalies++;
        }
    }
    anomaliesSummary.setMetricId(metricId);
    anomaliesSummary.setStartTime(startTime);
    anomaliesSummary.setEndTime(endTime);
    anomaliesSummary.setNumAnomalies(mergedAnomalies.size());
    anomaliesSummary.setNumAnomaliesResolved(resolvedAnomalies);
    anomaliesSummary.setNumAnomaliesUnresolved(unresolvedAnomalies);
    return anomaliesSummary;
}
Also used : AnomaliesSummary(com.linkedin.thirdeye.dashboard.resources.v2.pojo.AnomaliesSummary) MergedAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO) AnomalyFeedbackDTO(com.linkedin.thirdeye.datalayer.dto.AnomalyFeedbackDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 97 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class DataResource method getMetricNamesForDataset.

//------------- endpoints to fetch summary -------------
@GET
@Path("summary/metrics")
public List<String> getMetricNamesForDataset(@QueryParam("dataset") String dataset) {
    List<MetricConfigDTO> metrics = new ArrayList<>();
    if (Strings.isNullOrEmpty(dataset)) {
        metrics.addAll(metricConfigDAO.findAll());
    } else {
        metrics.addAll(metricConfigDAO.findActiveByDataset(dataset));
    }
    List<String> metricsNames = new ArrayList<>();
    for (MetricConfigDTO metricConfigDTO : metrics) {
        metricsNames.add(metricConfigDTO.getName());
    }
    return metricsNames;
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 98 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class DataResource method getFiltersForMetric.

@GET
@Path("autocomplete/filters/metric/{metricId}")
public Map<String, List<String>> getFiltersForMetric(@PathParam("metricId") Long metricId) {
    Map<String, List<String>> filterMap = new HashMap<>();
    try {
        // TODO : cache this
        MetricConfigDTO metricConfigDTO = metricConfigDAO.findById(metricId);
        DatasetConfigDTO datasetConfigDTO = datasetConfigDAO.findByDataset(metricConfigDTO.getDataset());
        String dimensionFiltersJson = dimensionsFilterCache.get(datasetConfigDTO.getDataset());
        if (!Strings.isNullOrEmpty(dimensionFiltersJson)) {
            filterMap = OBJECT_MAPPER.readValue(dimensionFiltersJson, LinkedHashMap.class);
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new WebApplicationException(e);
    }
    return filterMap;
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) DatasetConfigDTO(com.linkedin.thirdeye.datalayer.dto.DatasetConfigDTO) WebApplicationException(javax.ws.rs.WebApplicationException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) ArrayList(java.util.ArrayList) WebApplicationException(javax.ws.rs.WebApplicationException) LinkedHashMap(java.util.LinkedHashMap) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 99 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class DataResource method getAnomalySummary.

@GET
@Path("dashboard/anomalysummary")
public Map<String, List<AnomaliesSummary>> getAnomalySummary(@QueryParam("dashboard") String dashboard, @QueryParam("timeRanges") String timeRanges) {
    List<Long> metricIds = getMetricIdsByDashboard(dashboard);
    List<String> timeRangesList = Lists.newArrayList(timeRanges.split(","));
    Map<String, Long> timeRangeToDurationMap = new HashMap<>();
    for (String timeRange : timeRangesList) {
        String[] tokens = timeRange.split("_");
        long duration = TimeUnit.MILLISECONDS.convert(Long.valueOf(tokens[0]), TimeUnit.valueOf(tokens[1]));
        timeRangeToDurationMap.put(timeRange, duration);
    }
    Map<String, List<AnomaliesSummary>> metricAliasToAnomaliesSummariesMap = new HashMap<>();
    for (Long metricId : metricIds) {
        List<AnomaliesSummary> summaries = new ArrayList<>();
        MetricConfigDTO metricConfig = metricConfigDAO.findById(metricId);
        String metricAlias = metricConfig.getAlias();
        String dataset = metricConfig.getDataset();
        long endTime = Utils.getMaxDataTimeForDataset(dataset);
        for (String timeRange : timeRangesList) {
            long startTime = endTime - timeRangeToDurationMap.get(timeRange);
            AnomaliesSummary summary = anomaliesResoure.getAnomalyCountForMetricInRange(metricId, startTime, endTime);
            summaries.add(summary);
        }
        metricAliasToAnomaliesSummariesMap.put(metricAlias, summaries);
    }
    return metricAliasToAnomaliesSummariesMap;
}
Also used : MetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.MetricConfigDTO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) AnomaliesSummary(com.linkedin.thirdeye.dashboard.resources.v2.pojo.AnomaliesSummary) List(java.util.List) ArrayList(java.util.ArrayList) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 100 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class IngraphMetricConfigResource method updateMetricConfig.

@GET
@Path("/update")
public String updateMetricConfig(@NotNull @QueryParam("id") long ingraphMetricConfigId, @QueryParam("rrdName") String rrdName, @QueryParam("metricName") String metricName, @QueryParam("dashboardName") String dashboardName, @QueryParam("metricDataType") String metricDataType, @QueryParam("metricSourceType") String metricSourceType, @QueryParam("container") String container) {
    try {
        IngraphMetricConfigDTO ingraphMetricConfigDTO = ingraphMetricConfigDao.findById(ingraphMetricConfigId);
        ingraphMetricConfigDTO.setRrdName(rrdName);
        ingraphMetricConfigDTO.setMetricName(metricName);
        ingraphMetricConfigDTO.setDashboardName(dashboardName);
        ingraphMetricConfigDTO.setContainer(container);
        ingraphMetricConfigDTO.setMetricDataType(metricDataType);
        ingraphMetricConfigDTO.setMetricSourceType(metricSourceType);
        int numRowsUpdated = ingraphMetricConfigDao.update(ingraphMetricConfigDTO);
        if (numRowsUpdated == 1) {
            return JsonResponseUtil.buildResponseJSON(ingraphMetricConfigDTO).toString();
        } else {
            return JsonResponseUtil.buildErrorResponseJSON("Failed to update metric id:" + ingraphMetricConfigId).toString();
        }
    } catch (Exception e) {
        return JsonResponseUtil.buildErrorResponseJSON("Failed to update metric id:" + ingraphMetricConfigId + ". Exception:" + e.getMessage()).toString();
    }
}
Also used : IngraphMetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Path (javax.ws.rs.Path)6273 Produces (javax.ws.rs.Produces)3678 GET (javax.ws.rs.GET)3072 POST (javax.ws.rs.POST)1783 Consumes (javax.ws.rs.Consumes)1440 ApiOperation (io.swagger.annotations.ApiOperation)1213 ApiResponses (io.swagger.annotations.ApiResponses)997 PUT (javax.ws.rs.PUT)850 IOException (java.io.IOException)677 DELETE (javax.ws.rs.DELETE)662 ArrayList (java.util.ArrayList)591 WebApplicationException (javax.ws.rs.WebApplicationException)556 Response (javax.ws.rs.core.Response)540 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)490 HashMap (java.util.HashMap)394 Timed (com.codahale.metrics.annotation.Timed)383 URI (java.net.URI)374 List (java.util.List)287 Map (java.util.Map)259 NotFoundException (javax.ws.rs.NotFoundException)258