use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class BaseTimeSyncedIteratorTest method queryAB_AggAll.
/**
* Queries for A and B but without a tag specifier, thus agging em all
*/
protected void queryAB_AggAll() throws Exception {
final ArrayList<TSSubQuery> subs = new ArrayList<TSSubQuery>(2);
TSSubQuery sub = new TSSubQuery();
HashMap<String, String> query_tags = new HashMap<String, String>(1);
sub = new TSSubQuery();
sub.setMetric("A");
sub.setTags(query_tags);
sub.setAggregator("sum");
subs.add(sub);
sub = new TSSubQuery();
sub.setMetric("B");
query_tags = new HashMap<String, String>(1);
sub.setTags(query_tags);
sub.setAggregator("sum");
subs.add(sub);
runQueries(subs);
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQueryTSUIDType.
@Test
public void parseQueryTSUIDType() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&tsuid=sum:010101");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
assertNotNull(tsq);
assertEquals("1h-ago", tsq.getStart());
assertNotNull(tsq.getQueries());
TSSubQuery sub = tsq.getQueries().get(0);
assertNotNull(sub);
assertEquals("sum", sub.getAggregator());
assertEquals(1, sub.getTsuids().size());
assertEquals("010101", sub.getTsuids().get(0));
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQueryMTypeWDSAndFill.
@Test
public void parseQueryMTypeWDSAndFill() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:1h-avg-lerp:sys.cpu.0");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
TSSubQuery sub = tsq.getQueries().get(0);
assertEquals("1h-avg-lerp", sub.getDownsample());
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQueryMTypeWGroupByFilterAndWildcardFilterSameTagK.
@Test
public void parseQueryMTypeWGroupByFilterAndWildcardFilterSameTagK() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=wildcard(*tsort)}" + "{host=wildcard(*quirm)}");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
TSSubQuery sub = tsq.getQueries().get(0);
sub.validateAndSetQuery();
assertEquals(2, sub.getFilters().size());
assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
assertTrue(sub.getFilters().get(1) instanceof TagVWildcardFilter);
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQuery2MType.
@Test
public void parseQuery2MType() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0&m=avg:sys.cpu.1");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
assertNotNull(tsq.getQueries());
assertEquals(2, tsq.getQueries().size());
TSSubQuery sub1 = tsq.getQueries().get(0);
assertNotNull(sub1);
assertEquals("sum", sub1.getAggregator());
assertEquals("sys.cpu.0", sub1.getMetric());
TSSubQuery sub2 = tsq.getQueries().get(1);
assertNotNull(sub2);
assertEquals("avg", sub2.getAggregator());
assertEquals("sys.cpu.1", sub2.getMetric());
}
Aggregations