@Override public CanaryScope buildCanaryScope(CanaryScope canaryScope) { Map<String, String> extendedParameters = Optional.ofNullable(canaryScope.getExtendedScopeParams()) .orElseThrow(() -> new IllegalArgumentException("New Relic requires extended parameters")); NewRelicCanaryScope newRelicCanaryScope = new NewRelicCanaryScope(); newRelicCanaryScope.setScope(canaryScope.getScope()); newRelicCanaryScope.setStart(canaryScope.getStart()); newRelicCanaryScope.setEnd(canaryScope.getEnd()); newRelicCanaryScope.setStep(canaryScope.getStep()); newRelicCanaryScope.setExtendedScopeParams(extendedParameters); newRelicCanaryScope.setScopeKey(getRequiredExtendedParam(SCOPE_KEY_KEY, extendedParameters)); return newRelicCanaryScope; }
.build(); CanaryScope canaryScope = new CanaryScope(); canaryScope.setScope(scope); canaryScope.setLocation(location); canaryScope.setStart(startTimeIso != null ? Instant.parse(startTimeIso) : null); canaryScope.setEnd(endTimeIso != null ? Instant.parse(endTimeIso) : null); canaryScope.setStep(step); canaryScope.setExtendedScopeParams(extendedScopeParams);
@Override public String buildQuery(String metricsAccountName, CanaryConfig canaryConfig, CanaryMetricConfig canaryMetricConfig, CanaryScope canaryScope) throws IOException { GraphiteCanaryMetricSetQueryConfig queryConfig = (GraphiteCanaryMetricSetQueryConfig) canaryMetricConfig.getQuery(); String query = queryConfig.getMetricName(); if (!Strings.isNullOrEmpty(canaryScope.getScope())) { query = query.replace(SCOPE_VARIABLE, canaryScope.getScope()); } if (!Strings.isNullOrEmpty(canaryScope.getLocation())) { query = query.replace(LOCATION_VARIABLE, canaryScope.getLocation()); } log.debug("Query sent to graphite: {}.", query); return query; }
PrometheusRemoteService prometheusRemoteService = credentials.getPrometheusRemoteService(); if (StringUtils.isEmpty(canaryScope.getStart())) { throw new IllegalArgumentException("Start time is required."); if (StringUtils.isEmpty(canaryScope.getEnd())) { throw new IllegalArgumentException("End time is required."); canaryScope.getStart().toString(), canaryScope.getEnd().toString(), canaryScope.getStep()); } finally { long endTime = registry.clock().monotonicTime(); MetricSet.builder() .name(canaryMetricConfig.getName()) .startTimeMillis(canaryScope.getStart().toEpochMilli()) .startTimeIso(canaryScope.getStart().toString()) .endTimeMillis(canaryScope.getEnd().toEpochMilli()) .endTimeIso(canaryScope.getEnd().toString()) .stepMillis(TimeUnit.SECONDS.toMillis(canaryScope.getStep())) .values(Collections.emptyList());
private void addScopeFilter(CanaryScope canaryScope, StringBuilder sb) { String scope = canaryScope.getScope(); if (scope != null) { String[] scopeParts = validateAndExtractScope(scope); sb.append(" AND "); sb.append(scopeParts[0] + "='" + scopeParts[1] +"'"); } }
new CanaryScope(scope, null, Instant.parse(start), Instant.parse(end), step, Collections.emptyMap());
.build(); CanaryScope canaryScope = new CanaryScope(); canaryScope.setScope(scope); canaryScope.setStart(start != null ? Instant.parse(start) : null); canaryScope.setEnd(end != null ? Instant.parse(end) : null);
Instant.ofEpochMilli(timeSeries.getMetadata().getEndTimeMillis()); Duration stepDuration = Duration.ofSeconds(canaryScope.getStep()); if (stepDuration.isZero()) { stepDuration = calculateStepDuration(timeSeries);
log.debug("extendedScopeParams={}", canaryScope.getExtendedScopeParams()); populateTemplateBindings(metricSetQuery, baseScopeAttributes, templateBindings, true); if (!CollectionUtils.isEmpty(canaryScope.getExtendedScopeParams())) { templateBindings.putAll(canaryScope.getExtendedScopeParams());
private void validateManadtoryParams(InfluxdbCanaryMetricSetQueryConfig queryConfig, CanaryScope canaryScope) { if (StringUtils.isEmpty(queryConfig.getMetricName())) { throw new IllegalArgumentException("Measurement is required to query metrics"); } if (null == canaryScope) { throw new IllegalArgumentException("CanaryScope is missing"); } if (null == canaryScope.getStart() || null == canaryScope.getEnd()) { throw new IllegalArgumentException("Start and End times are required"); } }
PrometheusRemoteService prometheusRemoteService = credentials.getPrometheusRemoteService(); if (StringUtils.isEmpty(canaryScope.getStart())) { throw new IllegalArgumentException("Start time is required."); if (StringUtils.isEmpty(canaryScope.getEnd())) { throw new IllegalArgumentException("End time is required."); canaryScope.getStart().toString(), canaryScope.getEnd().toString(), canaryScope.getStep()); } finally { long endTime = registry.clock().monotonicTime(); MetricSet.builder() .name(canaryMetricConfig.getName()) .startTimeMillis(canaryScope.getStart().toEpochMilli()) .startTimeIso(canaryScope.getStart().toString()) .endTimeMillis(canaryScope.getEnd().toEpochMilli()) .endTimeIso(canaryScope.getEnd().toString()) .stepMillis(TimeUnit.SECONDS.toMillis(canaryScope.getStep())) .values(Collections.emptyList());
@Override public String buildQuery(String metricsAccountName, CanaryConfig canaryConfig, CanaryMetricConfig canaryMetricConfig, CanaryScope canaryScope) { DatadogCanaryMetricSetQueryConfig queryConfig = (DatadogCanaryMetricSetQueryConfig)canaryMetricConfig.getQuery(); return queryConfig.getMetricName() + "{" + canaryScope.getScope() + "}"; }
.build(); CanaryScope canaryScope = new CanaryScope(scope, location, Instant.parse(start), Instant.parse(end), null, Collections.EMPTY_MAP);
.build(); CanaryScope canaryScope = new CanaryScope(); canaryScope.setScope(scope); canaryScope.setStart(start != null ? Instant.parse(start) : null); canaryScope.setEnd(end != null ? Instant.parse(end) : null);
Instant.ofEpochMilli(timeSeries.getMetadata().getEndTimeMillis()); Duration stepDuration = Duration.ofSeconds(canaryScope.getStep()); if (stepDuration.isZero()) { stepDuration = calculateStepDuration(timeSeries);
log.debug("extendedScopeParams={}", canaryScope.getExtendedScopeParams()); populateTemplateBindings(metricSetQuery, baseScopeAttributes, templateBindings, true); if (!CollectionUtils.isEmpty(canaryScope.getExtendedScopeParams())) { templateBindings.putAll(canaryScope.getExtendedScopeParams());
@Override public CanaryScope buildCanaryScope(CanaryScope canaryScope) { SignalFxCanaryScope signalFxCanaryScope = new SignalFxCanaryScope(); signalFxCanaryScope.setScope(canaryScope.getScope()); signalFxCanaryScope.setLocation(canaryScope.getLocation()); signalFxCanaryScope.setStart(canaryScope.getStart()); signalFxCanaryScope.setEnd(canaryScope.getEnd()); signalFxCanaryScope.setStep(canaryScope.getStep()); Optional.ofNullable(canaryScope.getExtendedScopeParams()).ifPresent(extendedParameters -> { signalFxCanaryScope.setScopeKey(extendedParameters.getOrDefault(SCOPE_KEY_KEY, null)); signalFxCanaryScope.setLocationKey(extendedParameters.getOrDefault(LOCATION_KEY_KEY, null)); signalFxCanaryScope.setExtendedScopeParams(extendedParameters); }); return signalFxCanaryScope; } }
DatadogRemoteService remoteService = accountCredentials.getDatadogRemoteService(); if (StringUtils.isEmpty(canaryScope.getStart())) { throw new IllegalArgumentException("Start time is required."); if (StringUtils.isEmpty(canaryScope.getEnd())) { throw new IllegalArgumentException("End time is required."); credentials.getApiKey(), credentials.getApplicationKey(), (int)canaryScope.getStart().getEpochSecond(), (int)canaryScope.getEnd().getEpochSecond(), query );
.build(); CanaryScope canaryScope = new CanaryScope(); canaryScope.setScope(scope); canaryScope.setLocation(location); canaryScope.setStart(startTimeIso != null ? Instant.parse(startTimeIso) : null); canaryScope.setEnd(endTimeIso != null ? Instant.parse(endTimeIso) : null); canaryScope.setStep(step); canaryScope.setExtendedScopeParams(extendedScopeParams);