Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Support treat missing data. #479

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lib/terraforming/resource/cloud_watch_alarm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def alarm_attributes(alarm)
"period" => alarm.period.to_s,
"statistic" => alarm.statistic,
"threshold" => alarm.threshold.to_s,
"treat_missing_data" => alarm.treat_missing_data,
"unit" => sanitize(alarm.unit)
}
add_checksummed_attributes(attributes, alarm)
Expand Down
3 changes: 2 additions & 1 deletion lib/terraforming/template/tf/cloud_watch_alarm.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "aws_cloudwatch_metric_alarm" "<%= normalize_module_name(alarm.alarm_na
period = "<%= alarm.period %>"
statistic = "<%= alarm.statistic %>"
threshold = "<%= alarm.threshold %>"
treat_missing_data = "<%= alarm.treat_missing_data %>"
alarm_description = "<%= alarm.alarm_description %>"
<%- unless alarm.ok_actions.empty? -%>
ok_actions = <%= alarm.ok_actions %>
Expand All @@ -19,7 +20,7 @@ resource "aws_cloudwatch_metric_alarm" "<%= normalize_module_name(alarm.alarm_na
actions_enabled = <%= alarm.actions_enabled %>
<%- end -%>
<%- unless alarm.dimensions.empty? -%>
dimensions {
dimensions = {
<% alarm.dimensions.each do |dimension| -%>
<%= dimension.name %> = "<%= dimension.value %>"
<% end -%>
Expand Down
8 changes: 7 additions & 1 deletion spec/lib/terraforming/resource/cloud_watch_alarm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Resource
ok_actions: [],
period: 300,
statistic: "Average",
treat_missing_data: "missing",
threshold: 10000.0
},
{
Expand All @@ -37,6 +38,7 @@ module Resource
ok_actions: [],
period: 120,
statistic: "Average",
treat_missing_data: "notBreaching",
threshold: 80.0
}
]
Expand All @@ -58,9 +60,10 @@ module Resource
period = "300"
statistic = "Average"
threshold = "10000.0"
treat_missing_data = "missing"
alarm_description = ""
alarm_actions = ["arn:aws:sns:region:account:lambda-alerts"]
dimensions {
dimensions = {
FunctionName = "beep-beep"
}
}
Expand All @@ -74,6 +77,7 @@ module Resource
period = "120"
statistic = "Average"
threshold = "80.0"
treat_missing_data = "notBreaching"
alarm_description = "This metric monitors ec2 cpu utilization"
actions_enabled = false
}
Expand Down Expand Up @@ -102,6 +106,7 @@ module Resource
"period" => "300",
"statistic" => "Average",
"threshold" => "10000.0",
"treat_missing_data" => "missing",
"unit" => "",
"insufficient_data_actions.#" => "0",
"alarm_actions.#" => "1",
Expand All @@ -128,6 +133,7 @@ module Resource
"period" => "120",
"statistic" => "Average",
"threshold" => "80.0",
"treat_missing_data" => "notBreaching",
"unit" => "",
"insufficient_data_actions.#" => "0",
"alarm_actions.#" => "0",
Expand Down