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;
}
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;
}
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);
}
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;
}
Aggregations