Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "spinnaker_canary_config" resource/data source #55

Merged
merged 4 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## 0.2.2 (Unreleased)
### Improvements
* Add `spinnaker_canary_config` resource/data source for defining canary config. ([#54](https://github.com/mercari/terraform-provider-spinnaker/pull/54))
* Note that this currently supports only Cloud Monitoring.

### Bug fixes
* Fixed `gate_endpoint` attribute is not loaded. ([#52](https://github.com/mercari/terraform-provider-spinnaker/pull/52))

## 0.2.1 (July 27, 2020)
### Bug fixes
Expand Down
57 changes: 57 additions & 0 deletions docs/data-resources/canary_config.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# spinnaker_canary_config Data Source

Provides a Spinnaker canary config data source.

## Example Usage

```hcl
# Create a new Spinnaker canary config
data "spinnaker_canary_config" "canary_config" {}
```

## Argument Reference

The following arguments are supported:

* `id` - Canary config ID.
* `name` - Name of the canary configuration.
* `description` - Description for the canary config.
* `applications` - List of the application which the canary config belongs.
* `metric` - List of the metric to analyze.
* `classifier` - Classification configuration.

## Attribute Reference

* `metric` - Group of provider's metrics.
* `name` - Human readable name of the metric.
* `query` - Query config object for your metric source type.
* `groups` - List of the group which this query belongs to.
* `analysis_configurations` - (Optional) Analysis configuration, describes how to judge a given metric.
* `query` - Block for querying the metric from the service.
* `type` - Type of the metric.
* `service_type` - Type of the service that is providing the metric.
* `per_series_aligner` - Algorithm to align individual time series.
* `cross_series_reducer` - Algorithm to group multiple time series together.
* `group_by_fields` - Group by resource or metric labels to reduce the number of time series.
* `resource_type` - Type of the resource
* `metric_type` - Typo of the metric
* `analysis_configurations` - Canary analysis configuration.
* `canary` - Configuration for canary.
* `canary` - Configuration for canary.
* `direction` - Direction on how to judge the failure. Options are `increase`, `decrease` or `either`. Defaults to `increase`.
* `nan_strategy` - How to handle NaN values which can occur if the metric does not return data for a particular time interval. Options are `remove` or `replace`. Default is `remove`.
* `critical` - Fails on this metrics error or not.
* `must_have_data` - Use to fail a metric if data is missing.
* `effect_zize` - Controls how much different the metric needs to be to fail or fail critically.
* `outliers` - Controls how to classify and handle outliers.
* `effect_size` - Controls how much different the metric needs to be to fail or fail critically.
* `allowed_increase` - The multiplier increase that must be met for the metric to fail. Default to `1`.
* `allowed_decrease` - The multiplier decrease that must be met for the metric to fail. Default to `1`.
* `critical_increase` - The multiplier increase that must be met for the metric to be a critical failure and fail the entire analysis with a score of 0. Default to `1`.
* `critical_decrease` - The multiplier decrease that must be met for the metric to be a critical failure and fail the entire analysis with a score of 0. Default to `1`.
* `outliers` - Controls how to classify and handle outliers.
* `strategy` - Remove or keep outliers. Options are `remove` and `keep`. Default is `keep`.
* `outlier_factor` The degree of significance a data point has to differ from other observations to be considered an outlier. Default is `3.0`.
* `classifier` - Define how the metrics are classified.
* `group_wieghts` - Define the weight for each groups.
* `group_weights` - Define the weight for each groups by mapping the group and the weight.
89 changes: 89 additions & 0 deletions docs/resources/canary_config.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# spinnaker_canary_config Resource

Provides a Spinnaker canary config resource.

## Example Usage

```hcl
# Create a new Spinnaker canary config
resource "spinnaker_canary_config" "canary_config" {
name = "Test canary config"
description = "Canary config for the demo"
applications = ["${spinnaker_application.my_app.application}"]

metric {
name = "CPU metric"

query {
type = "stackdriver"
service_type = "stackdriver"
per_series_aligner = "ALIGN_DELTA"
resource_type = "k8s_node"
metric_type = "kubernetes.io/cpu"
}

groups = ["cpu"]
scope_name = "default"
}

classifier {
group_weights {
cpu = 100
}
}
}
```

## Argument Reference

The following arguments are supported:

* `name` - (Required) Name of the canary configuration.
* `description` - (Required) Description for the canary config.
* `applications` - (Required) List of the application which the canary config belongs.
* `metric` - (Required) List of the metric to analyze.
* `classifier` - (Required) Classification configuration.

## Attribute Reference

* `metric` - Group of provider's metrics.
* `name` - (Required) Human readable name of the metric.
* `query` - (Required) Query config object for your metric source type.
* `groups` - (Required) List of the group which this query belongs to.
* `analysis_configurations` - (Optional) Analysis configuration, describes how to judge a given metric.
* `query` - Block for querying the metric from the service.
* `type` - (Required) Type of the metric.
* `service_type` - (Required) Type of the service that is providing the metric.
* `per_series_aligner` - (Optional) Algorithm to align individual time series.
* `cross_series_reducer` - (Optional) Algorithm to group multiple time series together.
* `group_by_fields` - (Optional) Group by resource or metric labels to reduce the number of time series.
* `resource_type` - (Required) Type of the resource.
* `metric_type` - (Required) Typo of the metric.
* `analysis_configurations` - Canary analysis configuration.
* `canary` - (Required) Configuration for canary.
* `canary` - Configuration for canary.
* `direction` - (Optional) Direction on how to judge the failure. Options are `increase`, `decrease` or `either`. Defaults to `increase`.
* `nan_strategy` - (Optional) How to handle NaN values which can occur if the metric does not return data for a particular time interval. Options are `remove` or `replace`. Default is `remove`.
* `critical` - (Optional) Fails on this metrics error or not.
* `must_have_data` - (Optional) Used to fail a metric if data is missing.
* `effect_zize` - (Optional) Controls how much different the metric needs to be to fail or fail critically.
* `outliers` - (Optional) Controls how to classify and handle outliers.
* `effect_size` - Controls how much different the metric needs to be to fail or fail critically.
* `allowed_increase` - (Optional) The multiplier increase that must be met for the metric to fail. Default to `1`.
* `allowed_decrease` - (Optional) The multiplier decrease that must be met for the metric to fail. Default to `1`.
* `critical_increase` - (Optional) The multiplier increase that must be met for the metric to be a critical failure and fail the entire analysis with a score of 0. Default to `1`.
* `critical_decrease` - (Optional) The multiplier decrease that must be met for the metric to be a critical failure and fail the entire analysis with a score of 0. Default to `1`.
* `outliers` - Controls how to classify and handle outliers.
* `strategy` - (Optional) Remove or keep outliers. Options are `remove` and `keep`. Default is `keep`.
* `outlier_factor` - (Option) The degree of significance a data point has to differ from other observations to be considered an outlier. Default is `3.0`.
* `classifier` - Define how the metrics are classified.
* `group_wieghts` - (Required) Define the weight for each groups.
* `group_weights` - Define the weight for each groups by mapping the group and the weight.

## Import

Canary config can be imported using their id, e.g.

```
$ terraform import spinnaker_canary 9753bd1b-3a5c-4104-99ea-26fbc7c78ead
```
2 changes: 1 addition & 1 deletion spinnaker/api/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func CreateApplication(client *gate.GatewayClient, createAppTask CreateApplicati
return err
}
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return fmt.Errorf("Encountered an error saving application, status code: %data-resources", resp.StatusCode)
return fmt.Errorf("Encountered an error saving application, status code: %d", resp.StatusCode)
}
if !taskSucceeded(task) {
return fmt.Errorf("Encountered an error saving application, task output was: %v", task)
Expand Down
Loading