private String buildMapPendingUpdatesByApplicationKey(AccountCredentials credentials, String accountName) { return "kayenta:" + credentials.getType() + ":" + accountName + PENDING_UPDATES_KEY_SUFFIX; } }
/** * Generates warnings that will be propigated in the aggregated results. */ protected List<String> getResultsWarnings(MonitorKayentaCanaryContext context, CanaryExecutionStatusResponse statusResponse) { List<String> warnings = new LinkedList<>(); String credentialType = ""; if (context.getMetricsAccountName() != null) { Set<? extends AccountCredentials> allCredentials = accountCredentialsRepository.getAll(); Optional<? extends AccountCredentials> credential = allCredentials.stream() .filter(cred -> cred.getName().equals(context.getMetricsAccountName())) .findAny(); if (credential.isPresent()) { credentialType = credential.get().getType(); } } // Datadog doesn't return data points in the same way as other metrics providers // and so are excluded here. See this Github comment for more information: // https://github.com/spinnaker/kayenta/issues/283#issuecomment-397346975 final ObjectMapper om = new ObjectMapper(); if (! credentialType.equals("datadog") && statusResponse.getResult().getJudgeResult().getResults().stream() .anyMatch(canaryAnalysisResult -> om.convertValue(canaryAnalysisResult.getControlMetadata().get("stats"), Stats.class).getCount() < 50)) { warnings.add("One of the metrics returned fewer than 50 data points, which can reduce confidence in the final canary score."); } return warnings; } }
@ApiOperation(value = "Retrieve a list of all configured metrics services") @RequestMapping(method = RequestMethod.GET) List<MetricsServiceDetail> list() { Set<AccountCredentials> metricAccountCredentials = CredentialsHelper.getAllAccountsOfType(METRICS_STORE, accountCredentialsRepository); return metricAccountCredentials .stream() .map(account -> MetricsServiceDetail .builder() .name(account.getName()) .type(account.getType()) .locations(account.getLocations()) .recommendedLocations(account.getRecommendedLocations()) .build()) .collect(Collectors.toList()); } }
String pendingUpdatesKey = "kayenta:" + credentials.getType() + ":" + accountName + PENDING_UPDATES_KEY_SUFFIX; String mapByApplicationKey = "kayenta:" + credentials.getType() + ":" + accountName + MAP_BY_APPLICATION_KEY_SUFFIX; Set<String> oldMapByApplicationKeys = jedis.hkeys(mapByApplicationKey); Set<String> byApplicationKeysToDelete = new HashSet<>();
public Set<Map<String, Object>> getCanaryConfigSummarySet(AccountCredentials credentials, List<String> applications) { String accountName = credentials.getName(); String mapByApplicationKey = "kayenta:" + credentials.getType() + ":" + accountName + MAP_BY_APPLICATION_KEY_SUFFIX; Set<Map<String, Object>> canaryConfigSummarySet = new HashSet<>(); try (Jedis jedis = jedisPool.getResource()) { if (jedis.exists(mapByApplicationKey)) { if (applications != null && applications.size() > 0) { // If any applications were specified, populate the response with all of the canary configs scoped to those applications. for (String application : applications) { String appScopedCanaryConfigListJson = jedis.hget(mapByApplicationKey, application); populateCanaryConfigSummarySet(mapByApplicationKey, canaryConfigSummarySet, appScopedCanaryConfigListJson); } } else { // No applications were specified so populate the response with all persisted canary configs. List<String> allAppScopedCanaryConfigListJson = jedis.hvals(mapByApplicationKey); for (String appScopedCanaryConfigListJson : allAppScopedCanaryConfigListJson) { populateCanaryConfigSummarySet(mapByApplicationKey, canaryConfigSummarySet, appScopedCanaryConfigListJson); } } } else { throw new IllegalArgumentException("Canary config index not ready."); } populateWithPendingUpdates(credentials, accountName, jedis, canaryConfigSummarySet, applications); } return canaryConfigSummarySet; }
for (AccountCredentials credentials : configurationStoreAccountCredentialsSet) { String accountName = credentials.getName(); String mapByApplicationKey = "kayenta:" + credentials.getType() + ":" + accountName + MAP_BY_APPLICATION_KEY_SUFFIX;
private String buildMapPendingUpdatesByApplicationKey(AccountCredentials credentials, String accountName) { return "kayenta:" + credentials.getType() + ":" + accountName + PENDING_UPDATES_KEY_SUFFIX; } }
/** * Generates warnings that will be propigated in the aggregated results. */ protected List<String> getResultsWarnings(MonitorKayentaCanaryContext context, CanaryExecutionStatusResponse statusResponse) { List<String> warnings = new LinkedList<>(); String credentialType = ""; if (context.getMetricsAccountName() != null) { Set<? extends AccountCredentials> allCredentials = accountCredentialsRepository.getAll(); Optional<? extends AccountCredentials> credential = allCredentials.stream() .filter(cred -> cred.getName().equals(context.getMetricsAccountName())) .findAny(); if (credential.isPresent()) { credentialType = credential.get().getType(); } } // Datadog doesn't return data points in the same way as other metrics providers // and so are excluded here. See this Github comment for more information: // https://github.com/spinnaker/kayenta/issues/283#issuecomment-397346975 final ObjectMapper om = new ObjectMapper(); if (! credentialType.equals("datadog") && statusResponse.getResult().getJudgeResult().getResults().stream() .anyMatch(canaryAnalysisResult -> om.convertValue(canaryAnalysisResult.getControlMetadata().get("stats"), Stats.class).getCount() < 50)) { warnings.add("One of the metrics returned fewer than 50 data points, which can reduce confidence in the final canary score."); } return warnings; } }
String pendingUpdatesKey = "kayenta:" + credentials.getType() + ":" + accountName + PENDING_UPDATES_KEY_SUFFIX; String mapByApplicationKey = "kayenta:" + credentials.getType() + ":" + accountName + MAP_BY_APPLICATION_KEY_SUFFIX; Set<String> oldMapByApplicationKeys = jedis.hkeys(mapByApplicationKey); Set<String> byApplicationKeysToDelete = new HashSet<>();
public Set<Map<String, Object>> getCanaryConfigSummarySet(AccountCredentials credentials, List<String> applications) { String accountName = credentials.getName(); String mapByApplicationKey = "kayenta:" + credentials.getType() + ":" + accountName + MAP_BY_APPLICATION_KEY_SUFFIX; Set<Map<String, Object>> canaryConfigSummarySet = new HashSet<>(); try (Jedis jedis = jedisPool.getResource()) { if (jedis.exists(mapByApplicationKey)) { if (applications != null && applications.size() > 0) { // If any applications were specified, populate the response with all of the canary configs scoped to those applications. for (String application : applications) { String appScopedCanaryConfigListJson = jedis.hget(mapByApplicationKey, application); populateCanaryConfigSummarySet(mapByApplicationKey, canaryConfigSummarySet, appScopedCanaryConfigListJson); } } else { // No applications were specified so populate the response with all persisted canary configs. List<String> allAppScopedCanaryConfigListJson = jedis.hvals(mapByApplicationKey); for (String appScopedCanaryConfigListJson : allAppScopedCanaryConfigListJson) { populateCanaryConfigSummarySet(mapByApplicationKey, canaryConfigSummarySet, appScopedCanaryConfigListJson); } } } else { throw new IllegalArgumentException("Canary config index not ready."); } populateWithPendingUpdates(credentials, accountName, jedis, canaryConfigSummarySet, applications); } return canaryConfigSummarySet; }
for (AccountCredentials credentials : configurationStoreAccountCredentialsSet) { String accountName = credentials.getName(); String mapByApplicationKey = "kayenta:" + credentials.getType() + ":" + accountName + MAP_BY_APPLICATION_KEY_SUFFIX;