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

cloudwatch - Add Alarms on Metric Math Expressions #6551

Closed
nirpod opened this issue Nov 22, 2018 · 12 comments · Fixed by #6833
Closed

cloudwatch - Add Alarms on Metric Math Expressions #6551

nirpod opened this issue Nov 22, 2018 · 12 comments · Fixed by #6833
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/cloudwatch Issues and PRs that pertain to the cloudwatch service.
Milestone

Comments

@nirpod
Copy link

nirpod commented Nov 22, 2018

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

need to add support for this new feature:
Amazon CloudWatch Launches Ability to Add Alarms on Metric Math Expressions

New or Affected Resource(s)

aws cloudwatch alarms

References

https://aws.amazon.com/about-aws/whats-new/2018/11/amazon-cloudwatch-launches-ability-to-add-alarms-on-metric-math-expressions/

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/cloudwatch Issues and PRs that pertain to the cloudwatch service. labels Nov 25, 2018
@dpetzold
Copy link
Contributor

dpetzold commented Dec 5, 2018

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 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

@kakmt
Copy link

kakmt commented Jan 23, 2019

How's #6833 going?

@benlamonica
Copy link

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?

@shaiguitar
Copy link

Any update on this PR? Would be great to have a new version with working cw math expressions in place.

@shaiguitar
Copy link

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!

@bflad bflad added this to the v1.59.0 milestone Feb 11, 2019
@bflad
Copy link
Contributor

bflad commented Feb 11, 2019

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. 🚀

@shaiguitar
Copy link

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.

@bflad
Copy link
Contributor

bflad commented Feb 11, 2019

@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.

@shaiguitar
Copy link

Any update on a release with this feature (end of week)?

@bflad
Copy link
Contributor

bflad commented Feb 14, 2019

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.

@shaiguitar
Copy link

shaiguitar commented Feb 15, 2019 via email

@ghost
Copy link

ghost commented Mar 31, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/cloudwatch Issues and PRs that pertain to the cloudwatch service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants