Difference between revisions of "AWS::CloudWatch::Alarm"

From wikieduonline
Jump to navigation Jump to search
 
(12 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
===Autoscaling===
 
===Autoscaling===
*https://www.agilepartner.net/en/aws-cloudformation-part-6/
+
<ref>https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-cloudwatch.html</ref>
  
 
<pre> AppScaleUpPolicy:
 
<pre> AppScaleUpPolicy:
Line 22: Line 22:
 
       ScalingAdjustment: -1</pre>
 
       ScalingAdjustment: -1</pre>
  
===CPU alarm===
+
=== CPU alarm ===
<pre>CPUAlarmHigh:
+
CPUAlarmHigh:
     Type: AWS::CloudWatch::Alarm
+
     Type: [[AWS::CloudWatch::Alarm]]
 
     Properties:
 
     Properties:
 
       AlarmDescription: Scale-up if CPU > 80% for 5 minutes
 
       AlarmDescription: Scale-up if CPU > 80% for 5 minutes
Line 37: Line 37:
 
       - Name: AutoScalingGroupName
 
       - Name: AutoScalingGroupName
 
         Value: !Ref DeployAppASG
 
         Value: !Ref DeployAppASG
       ComparisonOperator: GreaterThanThreshold</pre>
+
       ComparisonOperator: GreaterThanThreshold
 +
 
 +
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html
  
 
  <pre> CPUAlarmLow:
 
  <pre> CPUAlarmLow:
Line 55: Line 57:
 
       ComparisonOperator: LessThanThreshold</pre>
 
       ComparisonOperator: LessThanThreshold</pre>
  
==SNS==
+
== [[SNS]] ==
 
<ref>https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-sns.html</ref>
 
<ref>https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-sns.html</ref>
  
<pre>"MySNSTopic" : {
+
MySNSTopic:
    "Type" : "AWS::SNS::Topic",
+
  Type: [[AWS::SNS::Topic]]
    "Properties" : {
+
  Properties:
        "Subscription" : [ {
+
    Subscription:
            "Endpoint" : "add valid email address",
+
    - Endpoint: "add valid email address"
            "Protocol" : "email"
+
      Protocol: email
        } ]
 
    }
 
}</pre>
 
  
 
== See also ==
 
== See also ==
 +
* {{Type AWS}}
 
* {{CloudWatch}}
 
* {{CloudWatch}}
  
 
[[Category:AWS]]
 
[[Category:AWS]]

Latest revision as of 10:46, 29 September 2021

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html

Autoscaling[edit]

[1]

 AppScaleUpPolicy:
    Type: AWS::AutoScaling::ScalingPolicy
    Properties:
      AdjustmentType: ChangeInCapacity
      AutoScalingGroupName: !Ref DeployAppASG
      Cooldown: '60'
      ScalingAdjustment: 1
AppScaleDownPolicy:
    Type: AWS::AutoScaling::ScalingPolicy
    Properties:
      AdjustmentType: ChangeInCapacity
      AutoScalingGroupName: !Ref DeployAppASG
      Cooldown: '300'
      ScalingAdjustment: -1

CPU alarm[edit]

CPUAlarmHigh:
   Type: AWS::CloudWatch::Alarm
   Properties:
     AlarmDescription: Scale-up if CPU > 80% for 5 minutes
     MetricName: CPUUtilization
     Namespace: AWS/EC2
     Statistic: Average
     Period: 300
     EvaluationPeriods: 2
     Threshold: 80
     AlarmActions: [!Ref AppScaleUpPolicy]
     Dimensions:
     - Name: AutoScalingGroupName
       Value: !Ref DeployAppASG
     ComparisonOperator: GreaterThanThreshold

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html

 CPUAlarmLow:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmDescription: Scale-down if CPU < 60% for 5 minutes
      MetricName: CPUUtilization
      Namespace: AWS/EC2
      Statistic: Average
      Period: 300
      EvaluationPeriods: 2
      Threshold: 80
      AlarmActions: [!Ref AppScaleDownPolicy]
      Dimensions:
      - Name: AutoScalingGroupName
        Value: !Ref DeployAppASG
      ComparisonOperator: LessThanThreshold

SNS[edit]

[2]

MySNSTopic:
 Type: AWS::SNS::Topic
 Properties:
   Subscription:
   - Endpoint: "add valid email address"
     Protocol: email

See also[edit]

  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-cloudwatch.html
  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-sns.html
  • Advertising: