17
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CloudFormationでAWS::CloudWatch::Alarmのテンプレートの書き方で困ったこと

Posted at

cloudwatch alarmのテンプレートを記述したのですが、AWSの説明であんまり理解できなかったので半分覚え書きで書いています。

cloudwatch alarmのリファレンス: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html

困ったこと

  • アラームの条件設定の対応がわからない
  • カスタムメトリクスの書き方がわからない
  • 各リソースのメトリクスの書き方がわからない

アラームの条件設定の対応がわからない

EvaluationPeriods

  • 指定した [Threshold] の値とデータを比較する時間。
  • Required: Yes
  • Type: Integer

Period

  • 指定した統計を適用する期間。60 の倍数で、時間を秒単位で指定します。
  • Required: Yes
  • Type: Integer

Threshold

  • 指定した [Statistic] の値と比較する値。
  • Required: Yes
  • Type: Double

ComparisonOperator

  • 指定した Statistic および Threshold を比較するときに使用する算術演算。AWS CloudFormation は、1 番目のオペランドとして Statistic の値を使用します。
  • 次の値を指定できます。GreaterThanOrEqualToThreshold(以上)、GreaterThanThreshold(超える)、LessThanThreshold(未満)、LessThanOrEqualToThreshold(以下)。
  • Required: Yes
  • Type: String

[Period]分間に[Threshold]回[ComparisonOperator]の状態が[EvaluationPeriods]回続いたらアラートを出す

カスタムメトリクスの書き方がわからない

↓URLにかかれているとおり、filterを作って
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html
Dimensionsにarnを書く

各リソースのメトリクスの書き方がわからない

例としてElasticBeanstalkを出しますがS3、SQSなど必要に応じて書き換えてください

  • DimensionsにはEBのarn
  • MetricNameはURLのをhttps://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/aeb-metricscollected.html
  • Namespaceは"AWS/リソース名"

下記のように書けばアラームがメトリクスが使えます。

      Dimensions:
        -
          Name: !Ref ElasticBeanstalkのarn
          Value: !Ref ElasticBeanstalkのarn
      MetricName: "ApplicationRequests5xx"
      Namespace: "AWS/ElasticBeanstalk"
17
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?