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));
}
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);
}
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);
}
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));
}
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));
}
Aggregations