Search in sources :

Example 1 with MetricStores

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();
}
Also used : MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 2 with MetricStores

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");
}
Also used : Path(java.nio.file.Path) MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MetricStores

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);
}
Also used : MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) ArrayList(java.util.ArrayList) StackdriverStore(com.netflix.spinnaker.halyard.config.model.v1.metricStores.stackdriver.StackdriverStore) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) DatadogStore(com.netflix.spinnaker.halyard.config.model.v1.metricStores.datadog.DatadogStore) PrometheusStore(com.netflix.spinnaker.halyard.config.model.v1.metricStores.prometheus.PrometheusStore)

Example 4 with MetricStores

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.");
    }
}
Also used : MetricStores(com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 5 with MetricStores

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);
}
Also used : DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Aggregations

MetricStores (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores)4 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 DatadogStore (com.netflix.spinnaker.halyard.config.model.v1.metricStores.datadog.DatadogStore)1 PrometheusStore (com.netflix.spinnaker.halyard.config.model.v1.metricStores.prometheus.PrometheusStore)1 StackdriverStore (com.netflix.spinnaker.halyard.config.model.v1.metricStores.stackdriver.StackdriverStore)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 MetricStore (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore)1 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)1 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)1 ServiceSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1