Search in sources :

Example 11 with ThirdEyeRequest

use of com.linkedin.thirdeye.client.ThirdEyeRequest in project pinot by linkedin.

the class ThirdEyeRequestGenerator method generateRequestsForAggregation.

public static List<ThirdEyeRequest> generateRequestsForAggregation(TimeOnTimeComparisonRequest comparisonRequest) {
    List<ThirdEyeRequest> requests = new ArrayList<>();
    ThirdEyeRequest baselineALLRequest = ThirdEyeRequestGenerator.generateRequest(ALL_BASELINE, comparisonRequest, comparisonRequest.getBaselineStart(), comparisonRequest.getBaselineEnd(), null, null);
    requests.add(baselineALLRequest);
    ThirdEyeRequest currentALLRequest = ThirdEyeRequestGenerator.generateRequest(ALL_CURRENT, comparisonRequest, comparisonRequest.getCurrentStart(), comparisonRequest.getCurrentEnd(), null, null);
    requests.add(currentALLRequest);
    return requests;
}
Also used : ArrayList(java.util.ArrayList) ThirdEyeRequest(com.linkedin.thirdeye.client.ThirdEyeRequest)

Example 12 with ThirdEyeRequest

use of com.linkedin.thirdeye.client.ThirdEyeRequest in project pinot by linkedin.

the class ThirdEyeRequestGenerator method generateRequest.

public static ThirdEyeRequest generateRequest(String name, TimeOnTimeComparisonRequest comparisonRequest, DateTime start, DateTime end, String groupByDimension, TimeGranularity aggTimeGranularity) {
    ThirdEyeRequestBuilder requestBuilder = new ThirdEyeRequestBuilder();
    // COMMON to ALL REQUESTS
    requestBuilder.setCollection(comparisonRequest.getCollectionName());
    requestBuilder.setFilterSet(comparisonRequest.getFilterSet());
    requestBuilder.setFilterClause(comparisonRequest.getFilterClause());
    List<MetricFunction> metricFunctionsFromExpressions = Utils.computeMetricFunctionsFromExpressions(comparisonRequest.getMetricExpressions());
    requestBuilder.setMetricFunctions(metricFunctionsFromExpressions);
    // REQUEST to get total value with out break down.
    requestBuilder.setStartTimeInclusive(start);
    requestBuilder.setEndTimeExclusive(end);
    if (groupByDimension != null) {
        requestBuilder.setGroupBy(groupByDimension);
    }
    if (aggTimeGranularity != null) {
        requestBuilder.setGroupByTimeGranularity(aggTimeGranularity);
    }
    ThirdEyeRequest request = requestBuilder.build(name);
    return request;
}
Also used : ThirdEyeRequestBuilder(com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder) MetricFunction(com.linkedin.thirdeye.client.MetricFunction) ThirdEyeRequest(com.linkedin.thirdeye.client.ThirdEyeRequest)

Example 13 with ThirdEyeRequest

use of com.linkedin.thirdeye.client.ThirdEyeRequest in project pinot by linkedin.

the class TimeSeriesHandler method handle.

public TimeSeriesResponse handle(TimeSeriesRequest timeSeriesRequest) throws Exception {
    List<Range<DateTime>> timeranges = new ArrayList<>();
    TimeGranularity aggregationTimeGranularity = timeSeriesRequest.getAggregationTimeGranularity();
    // time ranges
    DateTime start = timeSeriesRequest.getStart();
    DateTime end = timeSeriesRequest.getEnd();
    if (timeSeriesRequest.isEndDateInclusive()) {
        // ThirdEyeRequest is exclusive endpoint, so increment by one bucket
        end = end.plus(aggregationTimeGranularity.toMillis());
    }
    timeranges = TimeRangeUtils.computeTimeRanges(aggregationTimeGranularity, start, end);
    // create request
    ThirdEyeRequest request = createThirdEyeRequest("timeseries", timeSeriesRequest, start, end);
    Future<ThirdEyeResponse> responseFuture = queryCache.getQueryResultAsync(request);
    // 5 minutes timeout
    ThirdEyeResponse response = responseFuture.get(5, TimeUnit.MINUTES);
    TimeSeriesResponseParser timeSeriesResponseParser = new TimeSeriesResponseParser(response, timeranges, timeSeriesRequest.getAggregationTimeGranularity(), timeSeriesRequest.getGroupByDimensions());
    List<TimeSeriesRow> rows = timeSeriesResponseParser.parseResponse();
    // compute the derived metrics
    computeDerivedMetrics(timeSeriesRequest, rows);
    return new TimeSeriesResponse(rows);
}
Also used : ArrayList(java.util.ArrayList) TimeGranularity(com.linkedin.thirdeye.api.TimeGranularity) ThirdEyeResponse(com.linkedin.thirdeye.client.ThirdEyeResponse) Range(com.google.common.collect.Range) DateTime(org.joda.time.DateTime) ThirdEyeRequest(com.linkedin.thirdeye.client.ThirdEyeRequest)

Example 14 with ThirdEyeRequest

use of com.linkedin.thirdeye.client.ThirdEyeRequest in project pinot by linkedin.

the class SeverityComputationUtil method computeSeverity.

public Map<String, Object> computeSeverity(long currentWindowStart, long currentWindowEnd, long seasonalPeriod, long seasonCount) throws Exception {
    // CURRENT
    ThirdEyeRequest thirdEyeRequest = createThirdEyeRequest(currentWindowStart, currentWindowEnd);
    double currentSum = getSum(thirdEyeRequest);
    List<Pair<DateTime, DateTime>> intervals = getHistoryIntervals(currentWindowStart, currentWindowEnd, seasonalPeriod, seasonCount);
    double baselineSum = 0;
    int count = 0;
    for (Pair<DateTime, DateTime> pair : intervals) {
        thirdEyeRequest = createThirdEyeRequest(pair.getLeft().getMillis(), pair.getRight().getMillis());
        double sum = getSum(thirdEyeRequest);
        if (sum != 0d) {
            ++count;
            baselineSum += sum;
        }
    }
    double baselineSumAvg = baselineSum / count;
    double weight = (currentSum - baselineSumAvg) / baselineSumAvg;
    HashMap<String, Object> hashMap = Maps.newHashMap();
    hashMap.put("weight", weight);
    hashMap.put("currentSum", currentSum);
    hashMap.put("baselineSumAvg", baselineSumAvg);
    return hashMap;
}
Also used : DateTime(org.joda.time.DateTime) ThirdEyeRequest(com.linkedin.thirdeye.client.ThirdEyeRequest) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

ThirdEyeRequest (com.linkedin.thirdeye.client.ThirdEyeRequest)14 ArrayList (java.util.ArrayList)8 ThirdEyeResponse (com.linkedin.thirdeye.client.ThirdEyeResponse)7 ThirdEyeRequestBuilder (com.linkedin.thirdeye.client.ThirdEyeRequest.ThirdEyeRequestBuilder)5 Future (java.util.concurrent.Future)4 DateTime (org.joda.time.DateTime)4 TimeGranularity (com.linkedin.thirdeye.api.TimeGranularity)3 MetricFunction (com.linkedin.thirdeye.client.MetricFunction)3 Range (com.google.common.collect.Range)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 ResultSet (com.linkedin.pinot.client.ResultSet)1 ResultSetGroup (com.linkedin.pinot.client.ResultSetGroup)1 ThirdEyeAnomalyConfiguration (com.linkedin.thirdeye.anomaly.ThirdEyeAnomalyConfiguration)1 MonitorConfiguration (com.linkedin.thirdeye.anomaly.monitor.MonitorConfiguration)1 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)1 ThirdEyeClient (com.linkedin.thirdeye.client.ThirdEyeClient)1 MetricDataset (com.linkedin.thirdeye.client.cache.MetricDataset)1 QueryCache (com.linkedin.thirdeye.client.cache.QueryCache)1