need to add support for this new feature:
Amazon CloudWatch Launches Ability to Add Alarms on Metric Math Expressions
aws cloudwatch alarms
Below is a proposed implementation spec. Please let me know what you think.
Theaws_cloudwatch_metric_alarm
resource would be need to support a new nested block metric
which would look like the following:
metric {
stat {
name = "ConnectionsFailed"
namespace = "MyService"
period = 60
stat = "Sum"
}
id = "m1"
}
metric {
stat {
name = "ConnectionsDropped"
namespace = "MyService"
period = 60
stat = "Sum"
}
id = "m2"
}
metric {
stat {
name = "RequestsThrottled"
namespace = "MyService"
period = 60
stat = "Sum"
}
id = "m3"
}
metric {
stat {
name = "ConnectionAttempts"
namespace = "MyService"
period = 60
stat = "Sum"
}
id = "m4"
}
metric {
id = "error_total"
expression = "m1+m2+m3"
}
metric {
id = "error_rate"
expression = "(error_total/m4)*100"
label = "Total Connection Error Rate"
return_data = "true"
}
Where:
return_data
defaults to false.stat
and expression
are mutually exclusive.Notice I folded in the Metric
structure into MetricStat
and renamed MetricStat
to stat
. I think that makes more sense from a configuration usage perspective but now it is no longer one-to-one.
https://www.terraform.io/docs/providers/aws/r/cloudwatch_metric_alarm.html
https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html
https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#CloudWatch.PutMetricAlarm
https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#MetricDataQuery
https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#MetricStat
Hi @bflad,
Would you consider merging Metric Math Expression support in? Are there any specific concerns with this implementation? I need this functionality and have been waiting for a while now. Will you give us an idea of when this can be merged?
Any update on this PR? Would be great to have a new version with working cw math expressions in place.
Bump - looking forward to seeing this get in. If there's something else pending on this I am happy to take a look/help out. Thanks in advance!
Support for math expression metric alarms (via a new metric_query
configuration block) has been merged and will release with version 1.59.0 of the Terraform AWS Provider, likely middle of this week. The resource documentation will include an example of how to set these up. 🚀
Thanks @bflad - out of curiosity for the impatient; is there a method or docs on how to use a work-in-progress terraform AWS provider/git branch to test out the functionality until an official provider is released?
Thanks for all the work you do.
@shaiguitar the README instructions should get you on your way to a custom built provider locally (e.g., a Go 1.11.4+ environment using make build
) and points to the Terraform instructions for installing a plugin since you will want to use a local custom built binary instead of one downloaded by terraform init
. The only very recent change to those instructions as written is that working inside the GOPATH
is optional now since we have migrated this codebase to Go modules.
If you have any issues with those instructions, I would suggest opening a new GitHub issue.
Any update on a release with this feature (end of week)?
This has been released in version 1.59.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
Verified this works as expected, thanks!
On Thu, Feb 14, 2019, 18:46 Brian Flad <[email protected] wrote:
This has been released in version 1.59.0 of the AWS provider
https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md#1590-february-14-2019.
Please see the Terraform documentation on provider versioning
https://www.terraform.io/docs/configuration/providers.html#provider-versions
or reach out if you need any assistance upgrading.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/terraform-providers/terraform-provider-aws/issues/6551#issuecomment-463848966,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAM3jJWfI_ilgwgOLBdxTdVIa9C86rGks5vNfVKgaJpZM4Yu5Ts
.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Below is a proposed implementation spec. Please let me know what you think.
The
aws_cloudwatch_metric_alarm
resource would be need to support a new nested blockmetric
which would look like the following:Where:
return_data
defaults to false.stat
andexpression
are mutually exclusive.Notice I folded in the
Metric
structure intoMetricStat
and renamedMetricStat
tostat
. I think that makes more sense from a configuration usage perspective but now it is no longer one-to-one.https://www.terraform.io/docs/providers/aws/r/cloudwatch_metric_alarm.html
https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html
https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#CloudWatch.PutMetricAlarm
https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#MetricDataQuery
https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#MetricStat