use of com.linkedin.thirdeye.client.MetricExpression in project pinot by linkedin.
the class TimeOnTimeTest method generateGroupByTimeRequest.
// TABULAR
private static TimeOnTimeComparisonRequest generateGroupByTimeRequest() {
TimeOnTimeComparisonRequest comparisonRequest = new TimeOnTimeComparisonRequest();
String collection = "thirdeyeAbook";
comparisonRequest.setCollectionName(collection);
comparisonRequest.setBaselineStart(new DateTime(2016, 4, 1, 00, 00));
comparisonRequest.setBaselineEnd(new DateTime(2016, 4, 2, 00, 00));
comparisonRequest.setCurrentStart(new DateTime(2016, 4, 8, 00, 00));
comparisonRequest.setCurrentEnd(new DateTime(2016, 4, 9, 00, 00));
List<MetricFunction> metricFunctions = new ArrayList<>();
metricFunctions.add(new MetricFunction(MetricAggFunction.SUM, "__COUNT"));
List<MetricExpression> metricExpressions = Utils.convertToMetricExpressions(metricFunctions);
metricExpressions.add(new MetricExpression("submit_rate", "submits/impressions"));
comparisonRequest.setMetricExpressions(metricExpressions);
comparisonRequest.setAggregationTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
return comparisonRequest;
}
use of com.linkedin.thirdeye.client.MetricExpression in project pinot by linkedin.
the class TimeSeriesTest method generateGroupByTimeAndDimension.
private static TimeSeriesRequest generateGroupByTimeAndDimension() {
TimeSeriesRequest timeSeriesRequest = new TimeSeriesRequest();
timeSeriesRequest.setCollectionName(THIRDEYE_ABOOK);
timeSeriesRequest.setStart(START);
timeSeriesRequest.setEnd(START.plusHours(3));
timeSeriesRequest.setGroupByDimensions(ABOOK_DIMENSIONS);
List<MetricFunction> metricFunctions = new ArrayList<>();
metricFunctions.add(DEFAULT_METRIC_FUNCTION);
List<MetricExpression> metricExpressions = Utils.convertToMetricExpressions(metricFunctions);
timeSeriesRequest.setMetricExpressions(metricExpressions);
timeSeriesRequest.setAggregationTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
return timeSeriesRequest;
}
use of com.linkedin.thirdeye.client.MetricExpression in project pinot by linkedin.
the class TimeSeriesTest method generateGroupByTimeRequest.
private static TimeSeriesRequest generateGroupByTimeRequest() {
TimeSeriesRequest timeSeriesRequest = new TimeSeriesRequest();
timeSeriesRequest.setCollectionName(THIRDEYE_ABOOK);
timeSeriesRequest.setStart(START);
timeSeriesRequest.setEnd(START.plusDays(1));
List<MetricFunction> metricFunctions = new ArrayList<>();
metricFunctions.add(DEFAULT_METRIC_FUNCTION);
List<MetricExpression> metricExpressions = Utils.convertToMetricExpressions(metricFunctions);
metricExpressions.add(SUBMIT_RATE_EXPRESSION);
timeSeriesRequest.setMetricExpressions(metricExpressions);
timeSeriesRequest.setAggregationTimeGranularity(new TimeGranularity(1, TimeUnit.HOURS));
return timeSeriesRequest;
}
use of com.linkedin.thirdeye.client.MetricExpression in project pinot by linkedin.
the class PinotThirdEyeSummaryClient method main.
public static void main(String[] args) throws Exception {
String oFileName = "Cube.json";
// An interesting data set that difficult to tell because too many dark reds and blues (Granularity: DAYS)
// String collection = "thirdeyeKbmi";
// String metricName = "pageViews";
// DateTime baselineStart = new DateTime(1467788400000L);
// DateTime baselineEnd = new DateTime(1469862000000L);
// DateTime currentStart = new DateTime(1468393200000L);
// DateTime currentEnd = new DateTime(1470466800000L);
// An interesting data set that difficult to tell because most cells are light red or blue (Granularity: HOURS)
// String collection = "thirdeyeKbmi";
// String metricName = "mobilePageViews";
// DateTime baselineStart = new DateTime(1469628000000L);
// DateTime baselineEnd = new DateTime(1469714400000L);
// DateTime currentStart = new DateTime(1470232800000L);
// DateTime currentEnd = new DateTime(1470319200000L);
// A migration of Asia connections from other data center to lsg data center (Granularity: DAYS)
// Most contributors: India and China
// String collection = "thirdeyeAbook";
// String metricName = "totalFlows";
// DateTime baselineStart = new DateTime(2016, 7, 11, 00, 00);
// DateTime baselineEnd = new DateTime(2016, 7, 12, 00, 00);
// DateTime currentStart = new DateTime(2016, 7, 18, 00, 00);
// DateTime currentEnd = new DateTime(2016, 7, 19, 00, 00);
// National Holidays in India and several countries in Europe and Latin America. (Granularity: DAYS)
String collection = "thirdeyeKbmi";
String metricName = "desktopPageViews";
DateTime baselineStart = new DateTime(1470589200000L);
DateTime baselineEnd = new DateTime(1470675600000L);
DateTime currentStart = new DateTime(1471194000000L);
DateTime currentEnd = new DateTime(1471280400000L);
// String collection = "ptrans_additive";
// String metricName = "txProcessTime/__COUNT";
// DateTime baselineStart = new DateTime(1470938400000L);
// DateTime baselineEnd = new DateTime(1471024800000L);
// DateTime currentStart = new DateTime(1471543200000L);
// DateTime currentEnd = new DateTime(1471629600000L);
// Create ThirdEye client
List<String> argList = new ArrayList<String>(Arrays.asList(args));
if (argList.size() == 1) {
argList.add(0, "server");
}
int lastIndex = argList.size() - 1;
String thirdEyeConfigDir = argList.get(lastIndex);
String persistenceConfig = thirdEyeConfigDir + "/persistence.yml";
DaoProviderUtil.init(new File(persistenceConfig));
ThirdEyeConfiguration thirdEyeConfig = new ThirdEyeDashboardConfiguration();
thirdEyeConfig.setWhitelistCollections(collection);
thirdEyeConfig.setRootDir(thirdEyeConfigDir);
ThirdEyeCacheRegistry.initializeCaches(thirdEyeConfig);
ThirdEyeCacheRegistry CACHE_REGISTRY_INSTANCE = ThirdEyeCacheRegistry.getInstance();
List<MetricExpression> metricExpressions = Utils.convertToMetricExpressions(metricName, MetricAggFunction.SUM, collection);
System.out.println(metricExpressions);
OLAPDataBaseClient pinotClient = new PinotThirdEyeSummaryClient(CACHE_REGISTRY_INSTANCE.getQueryCache());
pinotClient.setCollection(collection);
pinotClient.setMetricExpression(metricExpressions.get(0));
pinotClient.setCurrentStartInclusive(currentStart);
pinotClient.setCurrentEndExclusive(currentEnd);
pinotClient.setBaselineStartInclusive(baselineStart);
pinotClient.setBaselineEndExclusive(baselineEnd);
List<List<String>> hierarchies = new ArrayList<>();
hierarchies.add(Lists.newArrayList("continent", "countryCode"));
hierarchies.add(Lists.newArrayList("browser_name", "browser_version"));
Dimensions dimensions;
try {
dimensions = new Dimensions(Utils.getSchemaDimensionNames(collection));
} catch (Exception e1) {
System.out.println("Failed to get dimensions names of the collection: " + collection);
String[] dimensionNames = { "browserName", "continent", "countryCode", "deviceName", "environment", "locale", "osName", "pageKey", "service", "sourceApp" };
System.out.println("Default dimension names are used:" + dimensionNames);
dimensions = new Dimensions(Lists.newArrayList(dimensionNames));
}
int maxDimensionSize = 3;
// Build the cube for computing the summary
Cube initCube = new Cube();
initCube.buildWithAutoDimensionOrder(pinotClient, dimensions, maxDimensionSize, hierarchies);
// initCube.buildWithManualDimensionOrder(pinotClient, dimensions);
int answerSize = 10;
boolean oneSideErrors = true;
Summary summary = new Summary(initCube);
System.out.println(summary.computeSummary(answerSize, oneSideErrors, maxDimensionSize));
try {
initCube.toJson(oFileName);
Cube cube = Cube.fromJson(oFileName);
System.out.println("Restored Cube:");
System.out.println(cube);
summary = new Summary(cube);
System.out.println(summary.computeSummary(answerSize, oneSideErrors, maxDimensionSize));
} catch (IOException e) {
System.err.println("WARN: Unable to save the cube to the file: " + oFileName);
e.printStackTrace();
}
// closing
System.exit(0);
}
use of com.linkedin.thirdeye.client.MetricExpression in project pinot by linkedin.
the class TimeOnTimeComparisonHandler method createThirdEyeRequest.
private static ThirdEyeRequest createThirdEyeRequest(String requestReference, TimeOnTimeComparisonRequest comparisonRequest, DateTime start, DateTime end) {
ThirdEyeRequestBuilder requestBuilder = ThirdEyeRequest.newBuilder();
requestBuilder.setCollection(comparisonRequest.getCollectionName());
requestBuilder.setStartTimeInclusive(start);
requestBuilder.setEndTimeExclusive(end);
requestBuilder.setFilterSet(comparisonRequest.getFilterSet());
requestBuilder.addGroupBy(comparisonRequest.getGroupByDimensions());
requestBuilder.setGroupByTimeGranularity(comparisonRequest.getAggregationTimeGranularity());
List<MetricExpression> metricExpressions = comparisonRequest.getMetricExpressions();
List<MetricFunction> metricFunctionsFromExpressions = Utils.computeMetricFunctionsFromExpressions(metricExpressions);
requestBuilder.setMetricFunctions(metricFunctionsFromExpressions);
return requestBuilder.build(requestReference);
}
Aggregations