use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mAvgLongSingleTSMissingACount.
@Test
public void run10mAvgLongSingleTSMissingACount() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
storePoint(1356998400, 20, Aggregators.SUM, interval);
storePoint(1356998400, 2, Aggregators.COUNT, interval);
storePoint(1356999000, 40, Aggregators.SUM, interval);
// storePoint(1356999000, 5, Aggregators.COUNT, interval);
storePoint(1356999600, 60, Aggregators.SUM, interval);
storePoint(1356999600, 3, Aggregators.COUNT, interval);
storePoint(1357000200, 80, Aggregators.SUM, interval);
storePoint(1357000200, 4, Aggregators.COUNT, interval);
Aggregator aggr = Aggregators.AVG;
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));
final SeekableView it = dps[0].iterator();
DataPoint dp = it.next();
assertEquals(1356998400000L, dp.timestamp());
assertEquals(10, dp.doubleValue(), 0.0001);
dp = it.next();
assertEquals(1356999600000L, dp.timestamp());
assertEquals(20, dp.doubleValue(), 0.0001);
dp = it.next();
assertEquals(1357000200000L, dp.timestamp());
assertEquals(20, dp.doubleValue(), 0.0001);
assertFalse(it.hasNext());
assertEquals(3, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mAvgLongSingleTS.
@Test
public void run10mAvgLongSingleTS() 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);
storeCount(start_timestamp, end_timestamp, false, false, interval, 2);
aggr = Aggregators.AVG;
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 = 300;
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 += interval.getIntervalSeconds() * 1000;
i += interval.getIntervalSeconds() / 2;
}
assertEquals(73, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run10mSumLongSingleTS.
@Test
public void run10mSumLongSingleTS() 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, 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 run10mAvgLongSingleTSMissingToZeroBookends.
@Test
public void run10mAvgLongSingleTSMissingToZeroBookends() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
// For this test, the spans on either side are zero'd
storePoint(1356998400, 20, Aggregators.SUM, interval);
// storePoint(1356998400, 2, Aggregators.COUNT, interval);
// storePoint(1356999000, 40, Aggregators.SUM, interval);
storePoint(1356999000, 5, Aggregators.COUNT, interval);
storePoint(1357084800, 60, Aggregators.SUM, interval);
storePoint(1357084800, 3, Aggregators.COUNT, interval);
storePoint(1357085400, 80, Aggregators.SUM, interval);
storePoint(1357085400, 4, Aggregators.COUNT, interval);
// storePoint(1357171200, 90, Aggregators.SUM, interval);
storePoint(1357171200, 3, Aggregators.COUNT, interval);
storePoint(1357171800, 100, Aggregators.SUM, interval);
// storePoint(1357171800, 5, Aggregators.COUNT, interval);
Aggregator aggr = Aggregators.AVG;
setQuery(interval.getInterval(), aggr, tags, aggr);
ts_query.setEnd("1359590400");
ts_query.validateAndSetQuery();
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));
final SeekableView it = dps[0].iterator();
DataPoint dp = it.next();
assertEquals(1357084800000L, dp.timestamp());
assertEquals(20, dp.doubleValue(), 0.0001);
dp = it.next();
assertEquals(1357085400000L, dp.timestamp());
assertEquals(20, dp.doubleValue(), 0.0001);
assertFalse(it.hasNext());
assertEquals(2, dps[0].size());
}
use of net.opentsdb.rollup.RollupInterval in project opentsdb by OpenTSDB.
the class TestTsdbQueryRollup method run15mSumLongSingleTS.
// This test shows us falling back to raw data if the requested downsample
// interval doesn't match a configured rollup
@Test
public void run15mSumLongSingleTS() throws Exception {
final RollupInterval interval = rollup_config.getRollupInterval("10m");
final Aggregator aggr = Aggregators.SUM;
long start_timestamp = 1356998400L;
long end_timestamp = 1357041600L;
storeLongRollup(start_timestamp, end_timestamp, false, false, interval, aggr);
// 15 minutes down sampling that falls back to raw data
final int time_interval = 15 * 60 * 1000;
setQuery("15m", 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));
long ts = start_timestamp * 1000;
double value = 435;
for (DataPoint dp : dps[0]) {
assertEquals(ts, dp.timestamp());
assertEquals(value, dp.doubleValue(), 0.00001);
if (value >= 8535.0) {
// last dp all by it's lonesom
value = 300;
} else {
value += 900;
}
ts += time_interval;
}
assertEquals(11, dps[0].size());
}
Aggregations