@ApiOperation(value = "Retrieve a canary config from object storage") @RequestMapping(value = "/{canaryConfigId:.+}", method = RequestMethod.GET) public CanaryConfig loadCanaryConfig(@RequestParam(required = false) final String configurationAccountName, @PathVariable String canaryConfigId) { String resolvedConfigurationAccountName = CredentialsHelper.resolveAccountByNameOrType(configurationAccountName, AccountCredentials.Type.CONFIGURATION_STORE, accountCredentialsRepository); StorageService configurationService = storageServiceRepository .getOne(resolvedConfigurationAccountName) .orElseThrow(() -> new IllegalArgumentException("No configuration service was configured; unable to read canary config from bucket.")); return configurationService.loadObject(resolvedConfigurationAccountName, ObjectType.CANARY_CONFIG, canaryConfigId); }
@Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository);
@ApiOperation(value = "Retrieve status and results for a canary run") @RequestMapping(value = "/{canaryExecutionId:.+}", method = RequestMethod.GET) public CanaryExecutionStatusResponse getCanaryResults(@RequestParam(required = false) final String storageAccountName, @PathVariable String canaryExecutionId) { String resolvedStorageAccountName = CredentialsHelper.resolveAccountByNameOrType(storageAccountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); Execution pipeline = executionRepository.retrieve(Execution.ExecutionType.PIPELINE, canaryExecutionId); return executionMapper.fromExecution(resolvedStorageAccountName, pipeline); }
@Scheduled(fixedDelayString = "#{@datadogConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository);
@ApiOperation(value = "Retrieve a canary judge result from object storage") @RequestMapping(value = "/{canaryJudgeResultId:.+}", method = RequestMethod.GET) public CanaryResult loadCanaryJudgeResult(@RequestParam(required = false) final String accountName, @PathVariable String canaryJudgeResultId) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to read canary judge result from bucket.")); return storageService.loadObject(resolvedAccountName, ObjectType.CANARY_RESULT, canaryJudgeResultId); }
@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()); } }
@ApiOperation(value = "Retrieve a metric set list from object storage") @RequestMapping(value = "/{metricSetListId:.+}", method = RequestMethod.GET) public List<MetricSet> loadMetricSetList(@RequestParam(required = false) final String accountName, @PathVariable String metricSetListId) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to read metric set list from bucket.")); return storageService.loadObject(resolvedAccountName, ObjectType.METRIC_SET_LIST, metricSetListId); }
CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.CONFIGURATION_STORE, accountCredentialsRepository);
@ApiOperation(value = "Retrieve a list of canary config ids and timestamps") @RequestMapping(method = RequestMethod.GET) public List<Map<String, Object>> listAllCanaryConfigs(@RequestParam(required = false) final String configurationAccountName, @RequestParam(required = false, value = "application") final List<String> applications) { String resolvedConfigurationAccountName = CredentialsHelper.resolveAccountByNameOrType(configurationAccountName, AccountCredentials.Type.CONFIGURATION_STORE, accountCredentialsRepository); StorageService configurationService = storageServiceRepository .getOne(resolvedConfigurationAccountName) .orElseThrow(() -> new IllegalArgumentException("No configuration service was configured; unable to list all canary configs.")); return configurationService.listObjectKeys(resolvedConfigurationAccountName, ObjectType.CANARY_CONFIG, applications, false); } }
@Scheduled(fixedDelayString = "#{@stackdriverConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() throws IOException { Set<AccountCredentials> accountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository); for (AccountCredentials credentials : accountCredentialsSet) { if (credentials instanceof GoogleNamedAccountCredentials) { GoogleNamedAccountCredentials stackdriverCredentials = (GoogleNamedAccountCredentials)credentials; ListMetricDescriptorsResponse listMetricDescriptorsResponse = stackdriverCredentials .getMonitoring() .projects() .metricDescriptors() .list("projects/" + stackdriverCredentials.getProject()) .execute(); List<MetricDescriptor> metricDescriptors = listMetricDescriptorsResponse.getMetricDescriptors(); if (!CollectionUtils.isEmpty(metricDescriptors)) { // TODO(duftler): Should we instead be building the union across all accounts? This doesn't seem quite right yet. metricDescriptorsCache = metricDescriptors; log.debug("Updated cache with {} metric descriptors via account {}.", metricDescriptors.size(), stackdriverCredentials.getName()); } else { log.debug("While updating cache, found no metric descriptors via account {}.", stackdriverCredentials.getName()); } } } } }
@ApiOperation(value = "Retrieve a metric set pair list from object storage") @RequestMapping(value = "/{metricSetPairListId:.+}", method = RequestMethod.GET) public List<MetricSetPair> loadMetricSetPairList(@RequestParam(required = false) final String accountName, @PathVariable final String metricSetPairListId) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to read metric set pair list from bucket.")); return storageService.loadObject(resolvedAccountName, ObjectType.METRIC_SET_PAIR_LIST, metricSetPairListId); }
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { Set<AccountCredentials> configurationStoreAccountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.CONFIGURATION_STORE, accountCredentialsRepository); int existingByApplicationIndexCount = 0;
@ApiOperation(value = "Delete a metric set pair list") @RequestMapping(value = "/{metricSetPairListId:.+}", method = RequestMethod.DELETE) public void deleteMetricSetPairList(@RequestParam(required = false) final String accountName, @PathVariable final String metricSetPairListId, HttpServletResponse response) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to delete metric set pair list.")); storageService.deleteObject(resolvedAccountName, ObjectType.METRIC_SET_PAIR_LIST, metricSetPairListId); response.setStatus(HttpStatus.NO_CONTENT.value()); }
@Scheduled(fixedDelayString = "#{@prometheusConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository);
@ApiOperation(value = "Delete a metric set list") @RequestMapping(value = "/{metricSetListId:.+}", method = RequestMethod.DELETE) public void deleteMetricSetList(@RequestParam(required = false) final String accountName, @PathVariable String metricSetListId, HttpServletResponse response) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to delete metric set list.")); storageService.deleteObject(resolvedAccountName, ObjectType.METRIC_SET_LIST, metricSetListId); response.setStatus(HttpStatus.NO_CONTENT.value()); }
@Scheduled(fixedDelayString = "#{@datadogConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() { Set<AccountCredentials> accountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository);
@ApiOperation(value = "Retrieve a list of canary judge result ids and timestamps") @RequestMapping(method = RequestMethod.GET) public List<Map<String, Object>> listAllCanaryJudgeResults(@RequestParam(required = false) final String accountName) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to list all canary judge results.")); return storageService.listObjectKeys(resolvedAccountName, ObjectType.CANARY_RESULT); } }
@Scheduled(fixedDelayString = "#{@stackdriverConfigurationProperties.metadataCachingIntervalMS}") public void updateMetricDescriptorsCache() throws IOException { Set<AccountCredentials> accountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.METRICS_STORE, accountCredentialsRepository); for (AccountCredentials credentials : accountCredentialsSet) { if (credentials instanceof GoogleNamedAccountCredentials) { GoogleNamedAccountCredentials stackdriverCredentials = (GoogleNamedAccountCredentials)credentials; ListMetricDescriptorsResponse listMetricDescriptorsResponse = stackdriverCredentials .getMonitoring() .projects() .metricDescriptors() .list("projects/" + stackdriverCredentials.getProject()) .execute(); List<MetricDescriptor> metricDescriptors = listMetricDescriptorsResponse.getMetricDescriptors(); if (!CollectionUtils.isEmpty(metricDescriptors)) { // TODO(duftler): Should we instead be building the union across all accounts? This doesn't seem quite right yet. metricDescriptorsCache = metricDescriptors; log.debug("Updated cache with {} metric descriptors via account {}.", metricDescriptors.size(), stackdriverCredentials.getName()); } else { log.debug("While updating cache, found no metric descriptors via account {}.", stackdriverCredentials.getName()); } } } } }
@ApiOperation(value = "Retrieve a list of metric set pair list ids and timestamps") @RequestMapping(method = RequestMethod.GET) public List<Map<String, Object>> listAllMetricSetPairLists(@RequestParam(required = false) final String accountName) { String resolvedAccountName = CredentialsHelper.resolveAccountByNameOrType(accountName, AccountCredentials.Type.OBJECT_STORE, accountCredentialsRepository); StorageService storageService = storageServiceRepository .getOne(resolvedAccountName) .orElseThrow(() -> new IllegalArgumentException("No storage service was configured; unable to list all metric set pair lists.")); return storageService.listObjectKeys(resolvedAccountName, ObjectType.METRIC_SET_PAIR_LIST); } }
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { Set<AccountCredentials> configurationStoreAccountCredentialsSet = CredentialsHelper.getAllAccountsOfType(AccountCredentials.Type.CONFIGURATION_STORE, accountCredentialsRepository); int existingByApplicationIndexCount = 0;