public Map<String, TopologyMetrics.ComponentMetric> getTopologyMetrics(Topology topology, String asUser) throws IOException { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); return topologyMetrics.getMetricsForTopology(CatalogToLayoutConverter.getTopologyLayout(topology), asUser); }
@GET @Path("/topologies/{id}") @Timed public Response getTopologyMetricsById(@PathParam("id") Long id, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ); Topology topology = catalogService.getTopology(id); if (topology != null) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); Map<String, TopologyMetrics.ComponentMetric> topologyMetrics = metricsService.getTopologyMetrics(topology, asUser); return WSUtils.respondEntity(topologyMetrics, OK); } throw EntityNotFoundException.byId(id.toString()); }
@GET @Path("/topologies/{id}/timeseries") @Timed public Response getTopologyMetricsViaTimeSeriesById(@PathParam("id") Long id, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ); assertTimeRange(from, to); Topology topology = catalogService.getTopology(id); if (topology != null) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); TopologyTimeSeriesMetrics.TimeSeriesComponentMetric topologyMetrics = metricsService.getTopologyStats(topology, from, to, asUser); return WSUtils.respondEntity(topologyMetrics, OK); } throw EntityNotFoundException.byId(id.toString()); }
TopologyMetrics.TopologyMetric topologyMetric = metricsService.getTopologyMetric(topology, asUser); List<Pair<String, Double>> latenciesTopN = metricsService.getTopNAndOtherComponentsLatency(topology, asUser, latencyTopN);
@GET @Path("/topologies/{id}/components/{topologyComponentId}/component_stats") @Timed public Response getComponentStats(@PathParam("id") Long id, @PathParam("topologyComponentId") Long topologyComponentId, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws IOException { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ); assertTimeRange(from, to); Topology topology = catalogService.getTopology(id); TopologyComponent topologyComponent = catalogService.getTopologyComponent(id, topologyComponentId); if (topology != null && topologyComponent != null) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); TopologyTimeSeriesMetrics.TimeSeriesComponentMetric metrics = metricsService.getComponentStats(topology, topologyComponent, from, to, asUser); return WSUtils.respondEntity(metrics, OK); } else if (topology == null) { throw EntityNotFoundException.byId("Topology: " + id.toString()); } else { // topologyComponent == null throw EntityNotFoundException.byId("TopologyComponent: " + id.toString()); } }
@GET @Path("/topologies/{id}/components/{topologyComponentId}/complete_latency") @Timed public Response getCompleteLatency(@PathParam("id") Long id, @PathParam("topologyComponentId") Long topologyComponentId, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ); assertTimeRange(from, to); Topology topology = catalogService.getTopology(id); TopologyComponent topologyComponent = catalogService.getTopologyComponent(id, topologyComponentId); if (topology != null && topologyComponent != null) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); Map<Long, Double> metrics = metricsService.getCompleteLatency(topology, topologyComponent, from, to, asUser); return WSUtils.respondEntity(metrics, OK); } else if (topology == null) { throw EntityNotFoundException.byId("Topology: " + id.toString()); } else { // topologyComponent == null throw EntityNotFoundException.byId("TopologyComponent: " + id.toString()); } }
@GET @Path("/topologies/{id}/components/{topologyComponentId}/kafka_topic_offsets") @Timed public Response getKafkaTopicOffsets(@PathParam("id") Long id, @PathParam("topologyComponentId") Long topologyComponentId, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws IOException { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, id, READ); assertTimeRange(from, to); Topology topology = catalogService.getTopology(id); TopologyComponent topologyComponent = catalogService.getTopologyComponent(id, topologyComponentId); if (topology != null && topologyComponent != null) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); Map<String, Map<Long, Double>> metrics = metricsService.getKafkaTopicOffsets(topology, topologyComponent, from, to, asUser); return WSUtils.respondEntity(metrics, OK); } else if (topology == null) { throw EntityNotFoundException.byId("Topology: " + id.toString()); } else { // topologyComponent == null throw EntityNotFoundException.byId("TopologyComponent: " + id.toString()); } }
final TopologyActionsService topologyActionsService = new TopologyActionsService(streamcatalogService, environmentService, fileStorage, modelRegistryClient, config, subject, transactionManager); final TopologyMetricsService topologyMetricsService = new TopologyMetricsService(environmentService, subject); final TopologyLogSearchService topologyLogSearchService = new TopologyLogSearchService(environmentService, subject);
public TopologyMetrics.TopologyMetric getTopologyMetric(Topology topology, String asUser) throws IOException { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); return topologyMetrics.getTopologyMetric(CatalogToLayoutConverter.getTopologyLayout(topology), asUser); }
TopologyTimeSeriesMetrics.TimeSeriesComponentMetric currentMetric = metricsService.getComponentStats(topology, component, from, to, asUser); TopologyTimeSeriesMetrics.TimeSeriesComponentMetric previousMetric = metricsService.getComponentStats(topology, component, from - (to - from), from - 1, asUser); if (clazz.equals(TopologySource.class)) { overviewMetric = ComponentMetricSummary.convertSourceMetric(currentMetric, previousMetric);
@GET @Path("/topologies/{topologyId}/metrics") @Timed public Response getTopology(@PathParam("topologyId") Long topologyId, @QueryParam("from") Long from, @QueryParam("to") Long to, @Context SecurityContext securityContext) throws IOException { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); assertTimeRange(from, to); Topology topology = catalogService.getTopology(topologyId); if (topology != null) { String asUser = WSUtils.getUserFromSecurityContext(securityContext); TopologyTimeSeriesMetrics.TimeSeriesComponentMetric topologyMetrics = metricsService.getTopologyStats(topology, from, to, asUser); long prevFrom = from - (to - from); long prevTo = from - 1; TopologyTimeSeriesMetrics.TimeSeriesComponentMetric prevTopologyMetrics = metricsService.getTopologyStats(topology, prevFrom, prevTo, asUser); if (!checkMetricsResponseHasFullRangeOfTime(prevTopologyMetrics, prevFrom, prevTo)) { prevTopologyMetrics = null; } ComponentMetricSummary viewModeComponentMetric = ComponentMetricSummary.convertTopologyMetric( topologyMetrics, prevTopologyMetrics); TopologyWithMetric metric = new TopologyWithMetric(topology, viewModeComponentMetric, topologyMetrics); return WSUtils.respondEntity(metric, OK); } throw EntityNotFoundException.byId(topologyId.toString()); }
public TopologyTimeSeriesMetrics.TimeSeriesComponentMetric getTopologyStats(Topology topology, Long from, Long to, String asUser) throws IOException { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); return topologyMetrics.getTopologyStats(CatalogToLayoutConverter.getTopologyLayout(topology), from, to, asUser); }
.map(Unchecked.function(s -> { ComponentMetricSummary overviewMetric; TopologyTimeSeriesMetrics.TimeSeriesComponentMetric currentMetric = metricsService.getComponentStats(topology, s, from, to, asUser); TopologyTimeSeriesMetrics.TimeSeriesComponentMetric previousMetric = metricsService.getComponentStats(topology, s, from - (to - from), from - 1, asUser); if (clazz.equals(TopologySource.class)) { overviewMetric = ComponentMetricSummary.convertSourceMetric(
public Map<Long, Double> getCompleteLatency(Topology topology, TopologyComponent component, long from, long to, String asUser) throws Exception { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); return topologyMetrics.getCompleteLatency(CatalogToLayoutConverter.getTopologyLayout(topology), CatalogToLayoutConverter.getComponentLayout(component), from, to, asUser); }
try { String asUser = WSUtils.getUserFromSecurityContext(securityContext); return Pair.of(c, metricsService.getComponentStats(topology, c, from, to, asUser)); } catch (IOException e) { throw new RuntimeException(e);
public Map<String, Map<Long, Double>> getKafkaTopicOffsets(Topology topology, TopologyComponent component, Long from, Long to, String asUser) throws IOException { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); return topologyMetrics.getkafkaTopicOffsets(CatalogToLayoutConverter.getTopologyLayout(topology), CatalogToLayoutConverter.getComponentLayout(component), from, to, asUser); }
public TopologyTimeSeriesMetrics.TimeSeriesComponentMetric getComponentStats(Topology topology, TopologyComponent component, Long from, Long to, String asUser) throws IOException { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); return topologyMetrics.getComponentStats(CatalogToLayoutConverter.getTopologyLayout(topology), CatalogToLayoutConverter.getComponentLayout(component), from, to, asUser); }
public List<Pair<String, Double>> getTopNAndOtherComponentsLatency(Topology topology, String asUser, int nOfTopN) throws IOException { TopologyMetrics topologyMetrics = getTopologyMetricsInstance(topology); Map<String, TopologyMetrics.ComponentMetric> metricsForTopology = topologyMetrics .getMetricsForTopology(CatalogToLayoutConverter.getTopologyLayout(topology), asUser); List<Pair<String, Double>> topNAndOther = new ArrayList<>(); List<ImmutablePair<String, Double>> latencyOrderedComponents = metricsForTopology.entrySet().stream() .map((x) -> new ImmutablePair<>(x.getValue().getComponentName(), x.getValue().getProcessedTime())) // reversed sort .sorted((c1, c2) -> { if (c2.getValue() == null) { // assuming c1 is bigger return -1; } else { return c2.getValue().compareTo(c1.getValue()); } }) .collect(toList()); latencyOrderedComponents.stream().limit(nOfTopN).forEachOrdered(topNAndOther::add); double sumLatencyOthers = latencyOrderedComponents.stream() .skip(nOfTopN).filter((x) -> x.getValue() != null) .mapToDouble(Pair::getValue).sum(); topNAndOther.add(new ImmutablePair<>("Others", sumLatencyOthers)); return topNAndOther; }