use of com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores in project halyard by spinnaker.
the class EditMetricStoresCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
MetricStores metricStores = new OperationHandler<MetricStores>().setOperation(Daemon.getMetricStores(currentDeployment, false)).setFailureMesssage("Failed to load metric stores.").get();
int originalHash = metricStores.hashCode();
metricStores.setPeriod(isSet(period) ? period : metricStores.getPeriod());
if (originalHash == metricStores.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setOperation(Daemon.setMetricStores(currentDeployment, !noValidate, metricStores)).setFailureMesssage("Failed to edit metric stores.").setSuccessMessage("Successfully updated metric stores.").get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores in project halyard by spinnaker.
the class MetricStoresController method setMetricStores.
@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setMetricStores(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMetricStores) {
MetricStores metricStores = objectMapper.convertValue(rawMetricStores, MetricStores.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> metricStores.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> metricStoresService.setMetricStores(deploymentName, metricStores));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> metricStoresService.validateMetricStores(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit all metric stores");
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores in project halyard by spinnaker.
the class SpinnakerMonitoringDaemonProfileFactory method setProfile.
@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
SpinnakerRuntimeSettings.Services services = endpoints.getServices();
ServiceSettings monitoringService = services.getMonitoringDaemon();
MetricStores metricStores = deploymentConfiguration.getMetricStores();
List<String> enabledMetricStores = new ArrayList<>();
List<String> files = new ArrayList<>();
DatadogStore datadogStore = metricStores.getDatadog();
if (datadogStore.isEnabled()) {
enabledMetricStores.add("datadog");
}
PrometheusStore prometheusStore = metricStores.getPrometheus();
if (prometheusStore.isEnabled()) {
enabledMetricStores.add("prometheus");
}
StackdriverStore stackdriverStore = metricStores.getStackdriver();
if (stackdriverStore.isEnabled()) {
enabledMetricStores.add("stackdriver");
files.addAll(backupRequiredFiles(stackdriverStore, deploymentConfiguration.getName()));
}
profile.appendContents(yamlToString(metricStores));
Server server = new Server().setHost(monitoringService.getHost()).setPort(monitoringService.getPort());
ServerConfig serverConfig = new ServerConfig();
serverConfig.setServer(server);
profile.appendContents(yamlToString(serverConfig));
Monitor monitor = new Monitor().setPeriod(metricStores.getPeriod()).setMetricStore(enabledMetricStores);
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setMonitor(monitor);
profile.appendContents(yamlToString(monitorConfig));
profile.appendContents(profile.getBaseContents());
profile.setRequiredFiles(files);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores in project halyard by spinnaker.
the class MetricStoresService method getMetricStores.
public MetricStores getMetricStores(String deploymentName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores();
List<MetricStores> matching = lookupService.getMatchingNodesOfType(filter, MetricStores.class);
switch(matching.size()) {
case 0:
MetricStores metricStores = new MetricStores();
setMetricStores(deploymentName, metricStores);
return metricStores;
case 1:
return matching.get(0);
default:
throw new RuntimeException("It shouldn't be possible to have multiple metricStores nodes. This is a bug.");
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores in project halyard by spinnaker.
the class MetricStoresService method setMetricStores.
public void setMetricStores(String deploymentName, MetricStores newMetricStores) {
DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
deploymentConfiguration.setMetricStores(newMetricStores);
}
Aggregations