use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run30mSumLongSingleTS.
// In this case we're downsampling rolled up values
@Test
public void run30mSumLongSingleTS() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041599L;
storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
setQuery("30m", aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals(METRIC_STRING, dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
double value = 3600;
long ts = start_timestamp * 1000;
for (DataPoint dp : dps[0]) {
assertEquals(value, dp.doubleValue(), 0);
assertEquals(ts, dp.timestamp());
value += 5400;
ts += (interval.getIntervalSeconds() * 3) * 1000;
}
assertEquals(24, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mMaxLongSingleTS.
@Test
public void run10mMaxLongSingleTS() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.MAX;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041600L;
storeLongRollup(1356998400L, end_timestamp, false, false, interval, aggr);
final int time_interval = interval.getIntervalSeconds();
setQuery(interval.getInterval(), aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals(METRIC_STRING, dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
int i = 600;
long ts = start_timestamp * 1000;
for (final DataPoint dp : dps[0]) {
assertFalse(dp.isInteger());
assertEquals(i, dp.doubleValue(), 0.0001);
assertEquals(ts, dp.timestamp());
ts += time_interval * 1000;
i += time_interval;
}
assertEquals(73, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mSumLongDoubleTSFilter.
// Make sure filtering on time series still operates
@Test
public void run10mSumLongDoubleTSFilter() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041600L;
storeLongRollup(1356998400L, end_timestamp, true, false, interval, aggr);
final int time_interval = interval.getIntervalSeconds();
setQuery(interval.getInterval(), aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals(METRIC_STRING, dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertEquals(TAGV_STRING, dps[0].getTags().get(TAGK_STRING));
int i = 600;
long ts = start_timestamp * 1000;
for (final DataPoint dp : dps[0]) {
assertFalse(dp.isInteger());
assertEquals(i, dp.doubleValue(), 0.0001);
assertEquals(ts, dp.timestamp());
ts += time_interval * 1000;
i += time_interval;
}
assertEquals(73, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingCount.
@Test
public void run10mAvgLongSingleTSMissingCount() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041600L;
storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
aggr = Aggregators.AVG;
setQuery(interval.getInterval(), aggr, tags, aggr);
query.configureFromQuery(ts_query, 0);
final DataPoints[] dps = query.run();
assertEquals(1, dps.length);
assertEquals("", dps[0].metricName());
assertTrue(dps[0].getAggregatedTags().isEmpty());
assertNull(dps[0].getAnnotations());
assertNull(dps[0].getTags().get(TAGK_STRING));
assertFalse(dps[0].iterator().hasNext());
assertEquals(0, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class MultiGetQuery method prepareRowBaseTimesRollup.
/**
* Generates a list of Unix Epoch Timestamps for the row key base times given
* the start and end times of the query and rollup interval given.
* @return A non-null list of at least one base row.
*/
@VisibleForTesting
List<Long> prepareRowBaseTimesRollup() {
final RollupInterval interval = rollup_query.getRollupInterval();
// standard TSDB table format, i.e. we're using the default table and schema
if (interval.getUnits() == 'h') {
return prepareRowBaseTimes();
} else {
final List<Long> row_base_times = new ArrayList<Long>((int) ((end_row_time - start_row_time) / interval.getIntervals()));
long ts = RollupUtils.getRollupBasetime(start_row_time, interval);
while (ts <= end_row_time) {
row_base_times.add(ts);
// TODO - possible this could overshoot in some cases. It shouldn't
// if the rollups are properly configured, but... you know. Check it.
ts = RollupUtils.getRollupBasetime(ts + (interval.getIntervalSeconds() * interval.getIntervals()), interval);
}
return row_base_times;
}
}
Aggregations