use of co.cask.cdap.api.metrics.MetricDeleteQuery in project cdap by caskdata.
the class MetricQueryParser method parseDelete.
static MetricDeleteQuery parseDelete(URI requestURI, String metricPrefix) throws MetricsPathException {
MetricDataQueryBuilder builder = new MetricDataQueryBuilder();
parseContext(requestURI.getPath(), builder);
builder.setStartTs(0);
builder.setEndTs(Integer.MAX_VALUE - 1);
builder.setMetricName(metricPrefix);
MetricDataQuery query = builder.build();
return new MetricDeleteQuery(query.getStartTs(), query.getEndTs(), query.getMetrics().keySet(), query.getSliceByTags());
}
use of co.cask.cdap.api.metrics.MetricDeleteQuery in project cdap by caskdata.
the class ApplicationLifecycleService method deleteMetrics.
/**
* Delete the metrics for an application.
*
* @param applicationId the application to delete metrics for.
*/
private void deleteMetrics(ApplicationId applicationId) throws Exception {
ApplicationSpecification spec = this.store.getApplication(applicationId);
long endTs = System.currentTimeMillis() / 1000;
Map<String, String> tags = Maps.newHashMap();
tags.put(Constants.Metrics.Tag.NAMESPACE, applicationId.getNamespace());
// add or replace application name in the tagMap
tags.put(Constants.Metrics.Tag.APP, spec.getName());
MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, tags);
metricStore.delete(deleteQuery);
}
use of co.cask.cdap.api.metrics.MetricDeleteQuery in project cdap by caskdata.
the class MetricsHandlerTestRun method testInterpolate.
@Test
public void testInterpolate() throws Exception {
long start = System.currentTimeMillis() / 1000;
long end = start + 3;
Map<String, String> sliceBy = getFlowletContext("interspace", "WordCount1", "WordCounter", "run1", "splitter");
MetricValues value = new MetricValues(sliceBy, "reads", start, 100, MetricType.COUNTER);
metricStore.add(value);
value = new MetricValues(sliceBy, "reads", end, 400, MetricType.COUNTER);
metricStore.add(value);
verifyRangeQueryResult("/v3/metrics/query?" + getTags("interspace", "WordCount1", "WordCounter", "splitter") + "&metric=system.reads&interpolate=step&start=" + start + "&end=" + end, 4, 700);
verifyRangeQueryResult("/v3/metrics/query?" + getTags("interspace", "WordCount1", "WordCounter", "splitter") + "&metric=system.reads&interpolate=linear&start=" + start + "&end=" + end, 4, 1000);
// delete the added metrics for testing interpolator
MetricDeleteQuery deleteQuery = new MetricDeleteQuery(start, end, sliceBy);
metricStore.delete(deleteQuery);
}
Aggregations