Search in sources :

Example 36 with TSSubQuery

use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.

the class TestQueryRpc method parseQueryMTypeWExplicitAndDSAndRate.

@Test
public void parseQueryMTypeWExplicitAndDSAndRate() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:explicit_tags:1m-sum:rate:sys.cpu.0{host=web01}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    assertNotNull(sub.getTags());
    assertEquals("literal_or(web01)", sub.getTags().get("host"));
    assertTrue(sub.getRate());
    assertTrue(sub.getExplicitTags());
    assertEquals("1m-sum", sub.getDownsample());
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 37 with TSSubQuery

use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.

the class TestQueryRpc method parseQueryMTypeWGroupByRegex.

@Test
public void parseQueryMTypeWGroupByRegex() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=" + TagVRegexFilter.FILTER_NAME + "(something(foo|bar))}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    sub.validateAndSetQuery();
    assertEquals(1, sub.getFilters().size());
    assertTrue(sub.getFilters().get(0) instanceof TagVRegexFilter);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TagVRegexFilter(net.opentsdb.query.filter.TagVRegexFilter) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

TSSubQuery (net.opentsdb.core.TSSubQuery)37 TSQuery (net.opentsdb.core.TSQuery)30 Test (org.junit.Test)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)26 ArrayList (java.util.ArrayList)10 TagVWildcardFilter (net.opentsdb.query.filter.TagVWildcardFilter)7 Callback (com.stumbleupon.async.Callback)4 Deferred (com.stumbleupon.async.Deferred)4 HashMap (java.util.HashMap)4 DataPoints (net.opentsdb.core.DataPoints)4 IOException (java.io.IOException)3 DataPoint (net.opentsdb.core.DataPoint)3 IncomingDataPoint (net.opentsdb.core.IncomingDataPoint)3 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)2 OutputStream (java.io.OutputStream)2 Map (java.util.Map)2 Query (net.opentsdb.core.Query)2 ExpressionIterator (net.opentsdb.query.expression.ExpressionIterator)2 TimeSyncedIterator (net.opentsdb.query.expression.TimeSyncedIterator)2