Search in sources :

Example 26 with MetricDataQuery

use of co.cask.cdap.api.metrics.MetricDataQuery in project cdap by caskdata.

the class MetricQueryParserTest method testFlow.

@Test
public void testFlow() throws MetricsPathException {
    MetricDataQuery query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/flowlets/flowlet1/process.bytes?count=60&start=1&end=61"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.process.bytes", query);
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/some.metric?summary=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1");
    assertMetricName("system.some.metric", query);
    // flow with runId
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/runs/1234/some.metric?summary=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1");
    assertMetricName("system.some.metric", query);
    Assert.assertEquals("1234", query.getSliceByTags().get(Tag.RUN_ID));
    // flowlet with runId
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/runs/1234/flowlets/flowlet1/some.metric?summary=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.some.metric", query);
    Assert.assertEquals("1234", query.getSliceByTags().get(Tag.RUN_ID));
}
Also used : MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) Test(org.junit.Test)

Example 27 with MetricDataQuery

use of co.cask.cdap.api.metrics.MetricDataQuery in project cdap by caskdata.

the class MetricQueryParserTest method testService.

@Test
public void testService() throws MetricsPathException {
    MetricDataQuery query = MetricQueryParser.parse(URI.create("/system/services/appfabric/query.received?aggregate=true"));
    verifyTags(query.getSliceByTags(), "system", Tag.COMPONENT, "appfabric");
    assertMetricName("system.query.received", query);
}
Also used : MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) Test(org.junit.Test)

Example 28 with MetricDataQuery

use of co.cask.cdap.api.metrics.MetricDataQuery in project cdap by caskdata.

the class MetricQueryParserTest method testQueryArgs.

@Test
public void testQueryArgs() throws MetricsPathException {
    MetricDataQuery query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?count=60"));
    Assert.assertEquals(60, query.getLimit());
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?aggregate=true"));
    Assert.assertEquals(Integer.MAX_VALUE, query.getResolution());
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?count=60&start=1&end=61&" + "resolution=1s"));
    Assert.assertEquals(1, query.getStartTs());
    Assert.assertEquals(61, query.getEndTs());
    Assert.assertEquals(1, query.getResolution());
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?count=60&start=1&end=61&resolution=1m"));
    Assert.assertEquals(1, query.getStartTs());
    Assert.assertEquals(61, query.getEndTs());
    Assert.assertEquals(60, query.getResolution());
    Assert.assertNull(query.getInterpolator());
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?start=1&end=61&resolution=60m"));
    Assert.assertEquals(1, query.getStartTs());
    Assert.assertEquals(61, query.getEndTs());
    Assert.assertEquals(3600, query.getResolution());
    Assert.assertNull(query.getInterpolator());
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?count=60&start=1&end=61&interpolate=step"));
    Assert.assertEquals(1, query.getStartTs());
    Assert.assertEquals(61, query.getEndTs());
    Assert.assertTrue(query.getInterpolator() instanceof Interpolators.Step);
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/reads?count=60&start=1&end=61&interpolate=linear"));
    Assert.assertEquals(1, query.getStartTs());
    Assert.assertEquals(61, query.getEndTs());
    Assert.assertTrue(query.getInterpolator() instanceof Interpolators.Linear);
}
Also used : Interpolators(co.cask.cdap.api.dataset.lib.cube.Interpolators) MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) Test(org.junit.Test)

Example 29 with MetricDataQuery

use of co.cask.cdap.api.metrics.MetricDataQuery in project cdap by caskdata.

the class MetricQueryParserTest method testUserServices.

@Test
public void testUserServices() throws MetricsPathException {
    MetricDataQuery query = MetricQueryParser.parse(URI.create("/system/apps/app1/services/serve1/reads?summary=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.SERVICE, "serve1");
    assertMetricName("system.reads", query);
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/services/serve1/handlers/handler1/reads?summary=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.SERVICE, "serve1", Tag.HANDLER, "handler1");
    assertMetricName("system.reads", query);
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/services/serve1/runs/runid123/handlers/handler1/reads?summary=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.SERVICE, "serve1", Tag.HANDLER, "handler1");
    assertMetricName("system.reads", query);
    Assert.assertEquals("runid123", query.getSliceByTags().get(Tag.RUN_ID));
}
Also used : MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) Test(org.junit.Test)

Example 30 with MetricDataQuery

use of co.cask.cdap.api.metrics.MetricDataQuery in project cdap by caskdata.

the class MetricQueryParserTest method testQueues.

@Test
public void testQueues() throws MetricsPathException {
    MetricDataQuery query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/flowlets/flowlet1/queues/queue1/process.bytes.in?aggregate=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.process.bytes.in", query);
    Assert.assertEquals("queue1", query.getSliceByTags().get(Tag.FLOWLET_QUEUE));
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/flowlets/flowlet1/queues/queue1/process.bytes.out?aggregate=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.process.bytes.out", query);
    Assert.assertEquals("queue1", query.getSliceByTags().get(Tag.FLOWLET_QUEUE));
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/flowlets/flowlet1/queues/queue1/process.events.in?aggregate=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.process.events.in", query);
    Assert.assertEquals("queue1", query.getSliceByTags().get(Tag.FLOWLET_QUEUE));
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/flowlets/flowlet1/queues/queue1/process.events.out?aggregate=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.process.events.out", query);
    Assert.assertEquals("queue1", query.getSliceByTags().get(Tag.FLOWLET_QUEUE));
    query = MetricQueryParser.parse(URI.create("/system/apps/app1/flows/flow1/runs/run123/flowlets/flowlet1/queues/queue1/" + "process.events.out?aggregate=true"));
    verifyTags(query.getSliceByTags(), Id.Namespace.DEFAULT.getId(), Tag.APP, "app1", Tag.FLOW, "flow1", Tag.FLOWLET, "flowlet1");
    assertMetricName("system.process.events.out", query);
    Assert.assertEquals("queue1", query.getSliceByTags().get(Tag.FLOWLET_QUEUE));
    Assert.assertEquals("run123", query.getSliceByTags().get(Tag.RUN_ID));
}
Also used : MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) Test(org.junit.Test)

Aggregations

MetricDataQuery (co.cask.cdap.api.metrics.MetricDataQuery)42 Test (org.junit.Test)25 MetricTimeSeries (co.cask.cdap.api.metrics.MetricTimeSeries)21 TimeValue (co.cask.cdap.api.dataset.lib.cube.TimeValue)11 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)4 ApplicationManager (co.cask.cdap.test.ApplicationManager)4 AggregationFunction (co.cask.cdap.api.dataset.lib.cube.AggregationFunction)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Collection (java.util.Collection)3 ObjectStore (co.cask.cdap.api.dataset.lib.ObjectStore)2 MetricStore (co.cask.cdap.api.metrics.MetricStore)2 QueueName (co.cask.cdap.common.queue.QueueName)2 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)2 SparkAppUsingObjectStore (co.cask.cdap.spark.app.SparkAppUsingObjectStore)2 SparkManager (co.cask.cdap.test.SparkManager)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1