/** * Search the metric store and return the collection of metric names available for the tag-values in search query * @param query * @return Collection of metric names */ public Collection<String> searchMetricNames(MetricSearchQuery query) { return metricStore.findMetricNames(query); }
/** * Search the metric store and return the collection of metric names available for the tag-values in search query * @param query * @return Collection of metric names */ public Collection<String> searchMetricNames(MetricSearchQuery query) { return metricStore.findMetricNames(query); }
private Collection<String> getMetrics(List<MetricTagValue> tagValues) { // we want to search the entire range, so startTimestamp is '0' and end Timestamp is Integer.MAX_VALUE and // limit is -1 , to include the entire search result. MetricSearchQuery searchQuery = new MetricSearchQuery(0, Integer.MAX_VALUE, -1, toTagValues(tagValues)); Collection<String> metricNames = metricStore.findMetricNames(searchQuery); return Lists.newArrayList(Iterables.filter(metricNames, Predicates.notNull())); }
private Collection<String> getMetrics(List<MetricTagValue> tagValues) { // we want to search the entire range, so startTimestamp is '0' and end Timestamp is Integer.MAX_VALUE and // limit is -1 , to include the entire search result. MetricSearchQuery searchQuery = new MetricSearchQuery(0, Integer.MAX_VALUE, -1, toTagValues(tagValues)); Collection<String> metricNames = metricStore.findMetricNames(searchQuery); return Lists.newArrayList(Iterables.filter(metricNames, Predicates.notNull())); }
private Map<String, Long> getSparkDetails(ProgramId sparkProgram, String runId) { Map<String, String> context = new HashMap<>(); context.put(Constants.Metrics.Tag.NAMESPACE, sparkProgram.getNamespace()); context.put(Constants.Metrics.Tag.APP, sparkProgram.getApplication()); context.put(Constants.Metrics.Tag.SPARK, sparkProgram.getProgram()); context.put(Constants.Metrics.Tag.RUN_ID, runId); List<TagValue> tags = new ArrayList<>(); for (Map.Entry<String, String> entry : context.entrySet()) { tags.add(new TagValue(entry.getKey(), entry.getValue())); } MetricSearchQuery metricSearchQuery = new MetricSearchQuery(0, 0, Integer.MAX_VALUE, tags); Collection<String> metricNames = metricStore.findMetricNames(metricSearchQuery); Map<String, Long> overallResult = new HashMap<>(); for (String metricName : metricNames) { Collection<MetricTimeSeries> resultPerQuery = metricStore.query( new MetricDataQuery(0, 0, Integer.MAX_VALUE, metricName, AggregationFunction.SUM, context, new ArrayList<String>())); for (MetricTimeSeries metricTimeSeries : resultPerQuery) { overallResult.put(metricTimeSeries.getMetricName(), metricTimeSeries.getTimeValues().get(0).getValue()); } } return overallResult; }
private Map<String, Long> getSparkDetails(ProgramId sparkProgram, String runId) { Map<String, String> context = new HashMap<>(); context.put(Constants.Metrics.Tag.NAMESPACE, sparkProgram.getNamespace()); context.put(Constants.Metrics.Tag.APP, sparkProgram.getApplication()); context.put(Constants.Metrics.Tag.SPARK, sparkProgram.getProgram()); context.put(Constants.Metrics.Tag.RUN_ID, runId); List<TagValue> tags = new ArrayList<>(); for (Map.Entry<String, String> entry : context.entrySet()) { tags.add(new TagValue(entry.getKey(), entry.getValue())); } MetricSearchQuery metricSearchQuery = new MetricSearchQuery(0, 0, Integer.MAX_VALUE, tags); Collection<String> metricNames = metricStore.findMetricNames(metricSearchQuery); Map<String, Long> overallResult = new HashMap<>(); for (String metricName : metricNames) { Collection<MetricTimeSeries> resultPerQuery = metricStore.query( new MetricDataQuery(0, 0, Integer.MAX_VALUE, metricName, AggregationFunction.SUM, context, new ArrayList<String>())); for (MetricTimeSeries metricTimeSeries : resultPerQuery) { overallResult.put(metricTimeSeries.getMetricName(), metricTimeSeries.getTimeValues().get(0).getValue()); } } return overallResult; }