Search in sources :

Example 1 with TagValue

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

the class DefaultMetricStore method findNextAvailableTags.

@Override
public Collection<TagValue> findNextAvailableTags(MetricSearchQuery query) throws Exception {
    Collection<DimensionValue> tags = cube.get().findDimensionValues(buildCubeSearchQuery(query));
    Collection<TagValue> result = Lists.newArrayList();
    for (DimensionValue dimensionValue : tags) {
        result.add(new TagValue(dimensionValue.getName(), dimensionValue.getValue()));
    }
    return result;
}
Also used : DimensionValue(co.cask.cdap.api.dataset.lib.cube.DimensionValue) TagValue(co.cask.cdap.api.metrics.TagValue)

Example 2 with TagValue

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

the class MetricsQueryHelper method tagValuesToHuman.

private List<MetricTagValue> tagValuesToHuman(Collection<TagValue> tagValues) {
    List<MetricTagValue> result = Lists.newArrayList();
    for (TagValue tagValue : tagValues) {
        String human = tagNameToHuman.get(tagValue.getName());
        human = human != null ? human : tagValue.getName();
        String value = tagValue.getValue() == null ? ANY_TAG_VALUE : tagValue.getValue();
        result.add(new MetricTagValue(human, value));
    }
    return result;
}
Also used : MetricTagValue(co.cask.cdap.proto.MetricTagValue) MetricTagValue(co.cask.cdap.proto.MetricTagValue) TagValue(co.cask.cdap.api.metrics.TagValue)

Example 3 with TagValue

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

the class WorkflowStatsSLAHttpHandler method getSparkDetails.

private Map<String, Long> getSparkDetails(ProgramId sparkProgram, String runId) throws Exception {
    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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MetricTimeSeries(co.cask.cdap.api.metrics.MetricTimeSeries) MetricSearchQuery(co.cask.cdap.api.metrics.MetricSearchQuery) TagValue(co.cask.cdap.api.metrics.TagValue) MetricDataQuery(co.cask.cdap.api.metrics.MetricDataQuery) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

TagValue (co.cask.cdap.api.metrics.TagValue)3 DimensionValue (co.cask.cdap.api.dataset.lib.cube.DimensionValue)1 MetricDataQuery (co.cask.cdap.api.metrics.MetricDataQuery)1 MetricSearchQuery (co.cask.cdap.api.metrics.MetricSearchQuery)1 MetricTimeSeries (co.cask.cdap.api.metrics.MetricTimeSeries)1 MetricTagValue (co.cask.cdap.proto.MetricTagValue)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1