Skip to content

Commit

Permalink
To support custom alarms with extended_statistic (#102)
Browse files Browse the repository at this point in the history
* Add extended_statistic for custom CW alarm

* Update README for extended_statistic

* Auto Format

* Fix extended_statistic for default alarms

---------

Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
  • Loading branch information
linhkikuchi and cloudpossebot committed Jan 31, 2023
1 parent 507b58d commit f4bf230
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Available targets:
| <a name="input_cpu_utilization_low_statistic"></a> [cpu\_utilization\_low\_statistic](#input\_cpu\_utilization\_low\_statistic) | The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` | `string` | `"Average"` | no |
| <a name="input_cpu_utilization_low_threshold_percent"></a> [cpu\_utilization\_low\_threshold\_percent](#input\_cpu\_utilization\_low\_threshold\_percent) | The value against which the specified statistic is compared | `number` | `10` | no |
| <a name="input_credit_specification"></a> [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instances | <pre>object({<br> cpu_credits = string<br> })</pre> | `null` | no |
| <a name="input_custom_alarms"></a> [custom\_alarms](#input\_custom\_alarms) | Map of custom CloudWatch alarms configurations | <pre>map(object({<br> alarm_name = string<br> comparison_operator = string<br> evaluation_periods = string<br> metric_name = string<br> namespace = string<br> period = string<br> statistic = string<br> threshold = string<br> treat_missing_data = string<br> ok_actions = list(string)<br> insufficient_data_actions = list(string)<br> dimensions_name = string<br> dimensions_target = string<br> alarm_description = string<br> alarm_actions = list(string)<br> }))</pre> | `{}` | no |
| <a name="input_custom_alarms"></a> [custom\_alarms](#input\_custom\_alarms) | Map of custom CloudWatch alarms configurations | <pre>map(object({<br> alarm_name = string<br> comparison_operator = string<br> evaluation_periods = string<br> metric_name = string<br> namespace = string<br> period = string<br> statistic = string<br> extended_statistic = string<br> threshold = string<br> treat_missing_data = string<br> ok_actions = list(string)<br> insufficient_data_actions = list(string)<br> dimensions_name = string<br> dimensions_target = string<br> alarm_description = string<br> alarm_actions = list(string)<br> }))</pre> | `{}` | no |
| <a name="input_default_alarms_enabled"></a> [default\_alarms\_enabled](#input\_default\_alarms\_enabled) | Enable or disable cpu and memory Cloudwatch alarms | `bool` | `true` | no |
| <a name="input_default_cooldown"></a> [default\_cooldown](#input\_default\_cooldown) | The amount of time, in seconds, after a scaling activity completes before another scaling activity can start | `number` | `300` | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
Expand Down
3 changes: 3 additions & 0 deletions autoscaling.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ locals {
namespace = "AWS/EC2"
period = var.cpu_utilization_high_period_seconds
statistic = var.cpu_utilization_high_statistic
extended_statistic = null
threshold = var.cpu_utilization_high_threshold_percent
dimensions_name = "AutoScalingGroupName"
dimensions_target = join("", aws_autoscaling_group.default.*.name)
Expand All @@ -50,6 +51,7 @@ locals {
namespace = "AWS/EC2"
period = var.cpu_utilization_low_period_seconds
statistic = var.cpu_utilization_low_statistic
extended_statistic = null
threshold = var.cpu_utilization_low_threshold_percent
dimensions_name = "AutoScalingGroupName"
dimensions_target = join("", aws_autoscaling_group.default.*.name)
Expand All @@ -74,6 +76,7 @@ resource "aws_cloudwatch_metric_alarm" "all_alarms" {
namespace = each.value.namespace
period = each.value.period
statistic = each.value.statistic
extended_statistic = each.value.extended_statistic
threshold = each.value.threshold
treat_missing_data = each.value.treat_missing_data
ok_actions = each.value.ok_actions
Expand Down
2 changes: 1 addition & 1 deletion docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
| <a name="input_cpu_utilization_low_statistic"></a> [cpu\_utilization\_low\_statistic](#input\_cpu\_utilization\_low\_statistic) | The statistic to apply to the alarm's associated metric. Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum` | `string` | `"Average"` | no |
| <a name="input_cpu_utilization_low_threshold_percent"></a> [cpu\_utilization\_low\_threshold\_percent](#input\_cpu\_utilization\_low\_threshold\_percent) | The value against which the specified statistic is compared | `number` | `10` | no |
| <a name="input_credit_specification"></a> [credit\_specification](#input\_credit\_specification) | Customize the credit specification of the instances | <pre>object({<br> cpu_credits = string<br> })</pre> | `null` | no |
| <a name="input_custom_alarms"></a> [custom\_alarms](#input\_custom\_alarms) | Map of custom CloudWatch alarms configurations | <pre>map(object({<br> alarm_name = string<br> comparison_operator = string<br> evaluation_periods = string<br> metric_name = string<br> namespace = string<br> period = string<br> statistic = string<br> threshold = string<br> treat_missing_data = string<br> ok_actions = list(string)<br> insufficient_data_actions = list(string)<br> dimensions_name = string<br> dimensions_target = string<br> alarm_description = string<br> alarm_actions = list(string)<br> }))</pre> | `{}` | no |
| <a name="input_custom_alarms"></a> [custom\_alarms](#input\_custom\_alarms) | Map of custom CloudWatch alarms configurations | <pre>map(object({<br> alarm_name = string<br> comparison_operator = string<br> evaluation_periods = string<br> metric_name = string<br> namespace = string<br> period = string<br> statistic = string<br> extended_statistic = string<br> threshold = string<br> treat_missing_data = string<br> ok_actions = list(string)<br> insufficient_data_actions = list(string)<br> dimensions_name = string<br> dimensions_target = string<br> alarm_description = string<br> alarm_actions = list(string)<br> }))</pre> | `{}` | no |
| <a name="input_default_alarms_enabled"></a> [default\_alarms\_enabled](#input\_default\_alarms\_enabled) | Enable or disable cpu and memory Cloudwatch alarms | `bool` | `true` | no |
| <a name="input_default_cooldown"></a> [default\_cooldown](#input\_default\_cooldown) | The amount of time, in seconds, after a scaling activity completes before another scaling activity can start | `number` | `300` | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ variable "custom_alarms" {
namespace = string
period = string
statistic = string
extended_statistic = string
threshold = string
treat_missing_data = string
ok_actions = list(string)
Expand Down

0 comments on commit f4bf230

Please sign in to comment.