private void deleteMetrics(NamespaceId namespaceId) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.NAMESPACE, namespaceId.getNamespace()); MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } }
private CubeDeleteQuery buildCubeDeleteQuery(MetricDeleteQuery query) { // note: delete query currently usually executed synchronously, // so we only attempt to delete totals, to avoid timeout return new CubeDeleteQuery(query.getStartTs(), query.getEndTs(), TOTALS_RESOLUTION, query.getSliceByTags(), query.getMetricNames(), query.getTagPredicate()); }
private CubeDeleteQuery buildCubeDeleteQuery(MetricDeleteQuery query) { // note: delete query currently usually executed synchronously, // so we only attempt to delete totals, to avoid timeout return new CubeDeleteQuery(query.getStartTs(), query.getEndTs(), TOTALS_RESOLUTION, query.getSliceByTags(), query.getMetricNames(), query.getTagPredicate()); }
private void deleteMetrics(NamespaceId namespaceId) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.NAMESPACE, namespaceId.getNamespace()); MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } }
@Override public void deleteAll() { // this will delete all aggregates metrics data delete(new MetricDeleteQuery(0, System.currentTimeMillis() / 1000, Collections.emptySet(), Collections.emptyMap(), Collections.emptyList())); // this will delete all timeseries data deleteBefore(System.currentTimeMillis() / 1000); }
@Override public void deleteAll() { // this will delete all aggregates metrics data delete(new MetricDeleteQuery(0, System.currentTimeMillis() / 1000, Collections.emptySet(), Collections.emptyMap(), Collections.emptyList())); // this will delete all timeseries data deleteBefore(System.currentTimeMillis() / 1000); }
private void deleteMetrics(ApplicationId applicationId, Iterable<String> flows) { LOG.debug("Deleting metrics for application {}", applicationId); for (String flow : flows) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.NAMESPACE, applicationId.getNamespace()); tags.put(Constants.Metrics.Tag.APP, applicationId.getApplication()); tags.put(Constants.Metrics.Tag.FLOW, flow); MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } } }
/** * Delete the "system.queue.pending" metrics for a flow or for all flows in an app or a namespace. * * @param namespace the namespace id; may only be null if the appId and flowId are null * @param appId the application id; may only be null if the flowId is null */ public static void deleteFlowPendingMetrics(MetricStore metricStore, @Nullable String namespace, @Nullable String appId, @Nullable String flowId) { Preconditions.checkArgument(namespace != null || appId == null, "Namespace may only be null if AppId is null"); Preconditions.checkArgument(appId != null || flowId == null, "AppId may only be null if FlowId is null"); Collection<String> names = Collections.singleton("system.queue.pending"); Map<String, String> tags = new LinkedHashMap<>(); if (namespace != null) { tags.put(Constants.Metrics.Tag.NAMESPACE, namespace); if (appId != null) { tags.put(Constants.Metrics.Tag.APP, appId); if (flowId != null) { tags.put(Constants.Metrics.Tag.FLOW, flowId); } } } LOG.info("Deleting 'system.queue.pending' metric for context {}", tags); // we must delete up to the current time - let's round up to the next second. long nextSecond = System.currentTimeMillis() / 1000 + 1; metricStore.delete(new MetricDeleteQuery(0L, nextSecond, names, tags, new ArrayList<>(tags.keySet()))); }
/** * Delete the metrics for an application. * * @param applicationId the application to delete metrics for. */ private void deleteMetrics(ApplicationId applicationId) { ApplicationSpecification spec = this.store.getApplication(applicationId); long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); 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, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); }
/** * Delete the metrics for an application. * * @param applicationId the application to delete metrics for. */ private void deleteMetrics(ApplicationId applicationId) { ApplicationSpecification spec = this.store.getApplication(applicationId); long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); 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, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); }
private void deleteMetrics(Set<ProgramId> programs) { for (ProgramId programId : programs) { LOG.debug("Deleting metrics for program {}", programId); String typeTag = getMetricsTag(programId.getType()); if (typeTag != null) { Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.NAMESPACE, programId.getNamespace()); tags.put(Constants.Metrics.Tag.APP, programId.getApplication()); tags.put(typeTag, programId.getProgram()); long endTs = System.currentTimeMillis() / 1000; MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } } }
/** * Delete the metrics for a profile. * * @param profileId the profile to delete metrics for. */ private void deleteMetrics(ProfileId profileId) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.PROFILE_SCOPE, profileId.getScope().name()); tags.put(Constants.Metrics.Tag.PROFILE, profileId.getProfile()); // if the profile is in user scope, we need to add the namespace info to distinguish the profile if (profileId.getScope().equals(EntityScope.USER)) { tags.put(Constants.Metrics.Tag.NAMESPACE, profileId.getNamespace()); } MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } }
/** * Delete the metrics for a profile. * * @param profileId the profile to delete metrics for. */ private void deleteMetrics(ProfileId profileId) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.PROFILE_SCOPE, profileId.getScope().name()); tags.put(Constants.Metrics.Tag.PROFILE, profileId.getProfile()); // if the profile is in user scope, we need to add the namespace info to distinguish the profile if (profileId.getScope().equals(EntityScope.USER)) { tags.put(Constants.Metrics.Tag.NAMESPACE, profileId.getNamespace()); } MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } }