Container InsightsでECSクラスターについてCloudWatch Application Insightsを設定した場合にどのようなCloudWatchアラームが設定されるのか確認してみた

Container InsightsでECSクラスターについてCloudWatch Application Insightsを設定した場合にどのようなCloudWatchアラームが設定されるのか確認してみた

アプリケーションごとのダッシュボードやアラームを管理したい場合に
2026.01.18

ECSでCloudWatch Application Insightsを設定した場合にどのようなCloudWatchアラームが設定されるのか確認したい

こんにちは、のんピ(@non____97)です。

皆さんはECSでCloudWatch Application Insightsを設定した場合にどのようなCloudWatchアラームが設定されるのか確認したいなと思ったことはありますか? 私はあります。

以下記事で紹介されているとおり、Container InsightsのコンソールからCloudWatch Application Insightsを簡単に有効化することが可能です。

https://dev.classmethod.jp/articles/ecs-container-insights-with-enhanced-observability-java-application/

Application Insightsを設定することで簡単にアプリケーションのダッシュボードやアラームを設定および、イベント管理をすることが可能です。

https://docs.aws.amazon.com/ja_jp/AmazonCloudWatch/latest/monitoring/appinsights-what-is.html

では、どのようなアラームが設定されるのでしょうか。ドキュメントを探してもどのようなアラームが設定されるのかの記載はありませんでした。実際に確認してみました。

いきなりまとめ

  • ECSでCloudWatch Application Insightsを設定した場合にどのようなCloudWatch Alarmが設定される
    • ALBのHTTPCode_Target_4XX_Count
    • ALBのHTTPCode_Target_5XX_Count
    • ECSクラスターのMemoryUtilized
    • ECSクラスターのCpuUtilized

やってみた

検証環境

検証環境は以下のとおりです。

検証環境構成図.png

以下記事で使用したものを流用します。

https://dev.classmethod.jp/articles/aws-firelens-to-s3-with-data-firehose-dynamic-partitioning/

コードは以下リポジトリに保存しています。

https://github.com/non-97/ecs-native-blue-green/tree/v1.0.1

CloudWatch Application Insightsの有効化

Application Insightsの有効化を行います。

有効化はContainer Insightsのコンソールから行います。

Application Insightsタブを確認するとアプリケーションのモニタリングが正常に有効になりました。結果が表示されるまでにはしばらく時間がかかります。結果を表示するには、更新ボタンを使用してください。と表示されていました。

1.Application Insights を自動設定.png

Application Insightsを自動設定をクリックし、有効化します。

2.正常に有効になりました.png

有効化がされたようです。

Application Insightsのダッシュボードの確認

しばらくすると、以下のように発生した問題を確認できました。バックエンド返した4XXエラーについてのようです。

3. ALB- Backend 4XX errors.png

Application Insightsのコンソールを確認すると、同様の内容を確認できました。

17.Application Insights 概要.png

Applicationsからアプリケーションを選択すると、以下のようにApplication Insightsのダッシュボードを確認できました。

4.Application Insights .png

4つほどのアラームが設定されており、1つがアラーム状態になっていることが分かります。

ダッシュボードはCPUとメモリ使用率のメトリクスになっていますね。

Container InsightsのALB: Backend 4XX errorsのリンクをクリックすると、以下のような画面になりました。

19.ALB- Backend 4XX errors.png

参考までに編集をクリックすると以下のような画面になります。

16.編集.png

コンポーネントの確認

コンポーネントの確認をします。

5.コンポーネント.png

タイプはECSクラスターのようです。コンポーネントとワークロードのリンクをクリックします。

以下のようにダッシュボードが確認できました。

6.コンポーネント_ダッシュボード.png

リソースタブをクリックします。ECSサービスがリソースとして登録されているようです。

7.リソース.png

選択して詳細を表示をクリックすると、ECSサービスが表示されていました。

8.ECSサービス.png

モニタリング対象ワークロードタブやログタブ、Metricsタブ、Alarmsタブは以下のとおりです。

9.モニタリング対象ワークロード.png
10.ログ.png
11.Metrics.png
12.Metrics2.png
13.アラーム.png

コンポーネントのモニタリングの管理

コンポーネントのモニタリングで扱うメトリクスを編集します。コンポーネントのモニタリングを管理をクリックします。

20.コンポーネントのモニタリングを管理.png

以下のようにモニタリングするメトリクスの管理やカスタムアラームを設定できる画面になりました。

21.次についてのモニタリングを管理- EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg.png

コンポーネントメトリクスではビルトインメトリクもしくはContainer Insightsで取得できるメトリクスを選択可能です。

22.コンポーネントメトリクス.png

ALBのメトリクスも以下のように選択可能です。

23.Application Load Balancer のメトリクス.png

今回はTaskCountActiveConnectionCountを追加して保存をクリックします。

24.保存.png

するとダッシュボードでメトリクスを追加または削除するからメトリクスの選択一覧を確認すると、先ほど追加したメトリクスを確認できるようになりました。

25.ダッシュボードで追跡するオンボードメトリクスを選択する.png

メトリクスを追加すると以下のようにダッシュボードにも反映されていました。

26.メトリクスが追加された.png

設定履歴の確認

設定履歴タブを確認します。

14.設定履歴.png

リソース ステータス 作成日 詳細
CLOUDWATCH_ALARM Info January 17, 2026, 23:36 (UTC+09:00) Not enough data to predict the threshold. Metric : TargetResponseTime. Component: arn:aws:elasticloadbalancing:us-east-1:<AWSアカウントID>:loadbalancer/app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c
CLOUDWATCH_METRIC Info January 17, 2026, 23:36 (UTC+09:00) Metric UnHealthyHostCount does not exist for component arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg, subcomponent arn:aws:elasticloadbalancing:us-east-1:<AWSアカウントID>:loadbalancer/app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c, alarm cannot be created. Possible reason might be metric misses data points for two weeks, or required workload to emit this metric not installed.
CLOUDWATCH_METRIC Info January 17, 2026, 23:36 (UTC+09:00) Metric PendingTaskCount does not exist for component arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg, alarm cannot be created. Possible reason might be metric misses data points for two weeks, or required workload to emit this metric not installed.
CLOUDWATCH_ALARM Info January 17, 2026, 23:36 (UTC+09:00) Not enough data to predict the threshold. Metric : StorageReadBytes. Component: arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
SNS_NOTIFICATIONS Info January 17, 2026, 23:36 (UTC+09:00) Problem notifications aren't enabled. Notifications can be enabled on the application edit page.
CLOUDWATCH_ALARM Info January 17, 2026, 23:36 (UTC+09:00) Not enough data to predict the threshold. Metric : NetworkTxBytes. Component: arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
CLOUDWATCH_METRIC Info January 17, 2026, 23:36 (UTC+09:00) Metric RunningTaskCount does not exist for component arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg, alarm cannot be created. Possible reason might be metric misses data points for two weeks, or required workload to emit this metric not installed.
CLOUDWATCH_ALARM Info January 17, 2026, 23:36 (UTC+09:00) Not enough data to predict the threshold. Metric : StorageWriteBytes. Component: arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
CLOUDWATCH_ALARM Info January 17, 2026, 23:36 (UTC+09:00) Not enough data to predict the threshold. Metric : NetworkRxBytes. Component: arn:aws:ecs:us-east-1:<AWSアカウントID>:cluster/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg

Not enough data to predict the threshold. MetricといくつかリソースCLOUDWATCH_ALARMのものがありますね。

対象の以下メトリクスは以下です。

  • ALBのTargetResponseTime
  • ECSクラスターのStorageReadBytes
  • ECSクラスターのStorageWriteBytes
  • ECSクラスターのNetworkTxBytes
  • ECSクラスターのNetworkRxBytes

後述確認するCloudWatchアラームにはありませんでした。

メッセージ的にCloudWatch Anomaly Detectionを設定しようとしていたのではないかと思ったのですが、CloudTrailを確認してもこのようなCloudWatchアラームを作成しようとした形跡はありませんでした。

ログパターンの確認

ログパターンは何も設定されていません。

15.ログパターン.png

CloudWatchアラームの確認

CloudWatchアラームの確認をします。

CloudWatch Alarmを確認すると以下のとおり4つ設定されていました。

18.アラーム.png

具体的には以下4メトリクスのアラームが設定されていました。

  • ALBのHTTPCode_Target_4XX_Count
  • ALBのHTTPCode_Target_5XX_Count
  • ECSクラスターのMemoryUtilized
  • ECSクラスターのCpuUtilized

各アラームの設定は以下のとおりです。

ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/AWS/ApplicationELB/HTTPCode_Target_4XX_Count/app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c/
Type: AWS::CloudWatch::Alarm
Properties:
    AlarmName: ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/AWS/ApplicationELB/HTTPCode_Target_4XX_Count/app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c/
    AlarmDescription: This is math expression alarm created and managed by the
        CloudWatch Application Insights. To make changes please go to your
        application's configuration in Application Insights
    Tags:
        - Key: ApplicationInsightsManaged
          Value: "TRUE"
    ActionsEnabled: true
    OKActions: []
    AlarmActions: []
    InsufficientDataActions: []
    Dimensions: []
    EvaluationPeriods: 2
    DatapointsToAlarm: 2
    Threshold: 0.7
    ComparisonOperator: GreaterThanOrEqualToThreshold
    TreatMissingData: notBreaching
    Metrics:
        - Id: m8
          Label: HTTPCode_Target_4XX_Count
          Expression: m8_HTTPCode_Target_4XX_Count/m8_RequestCount
        - Id: m8_HTTPCode_Target_4XX_Count
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: AWS/ApplicationELB
                  MetricName: HTTPCode_Target_4XX_Count
                  Dimensions:
                      - Name: LoadBalancer
                        Value: app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c
              Period: 300
              Stat: Sum
              Unit: Count
        - Id: m8_RequestCount
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: AWS/ApplicationELB
                  MetricName: RequestCount
                  Dimensions:
                      - Name: LoadBalancer
                        Value: app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c
              Period: 300
              Stat: Sum
              Unit: Count

ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/AWS/ApplicationELB/HTTPCode_Target_5XX_Count/app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c/
Type: AWS::CloudWatch::Alarm
Properties:
    AlarmName: ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/AWS/ApplicationELB/HTTPCode_Target_5XX_Count/app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c/
    AlarmDescription: This is math expression alarm created and managed by the
        CloudWatch Application Insights. To make changes please go to your
        application's configuration in Application Insights
    Tags:
        - Key: ApplicationInsightsManaged
          Value: "TRUE"
    ActionsEnabled: true
    OKActions: []
    AlarmActions: []
    InsufficientDataActions: []
    Dimensions: []
    EvaluationPeriods: 2
    DatapointsToAlarm: 2
    Threshold: 0.1
    ComparisonOperator: GreaterThanOrEqualToThreshold
    TreatMissingData: notBreaching
    Metrics:
        - Id: m7
          Label: HTTPCode_Target_5XX_Count
          Expression: m7_HTTPCode_Target_5XX_Count/m7_RequestCount
        - Id: m7_HTTPCode_Target_5XX_Count
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: AWS/ApplicationELB
                  MetricName: HTTPCode_Target_5XX_Count
                  Dimensions:
                      - Name: LoadBalancer
                        Value: app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c
              Period: 300
              Stat: Sum
              Unit: Count
        - Id: m7_RequestCount
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: AWS/ApplicationELB
                  MetricName: RequestCount
                  Dimensions:
                      - Name: LoadBalancer
                        Value: app/EcsNat-AlbCo-gB01lRgFgX9v/34111fdfed82112c
              Period: 300
              Stat: Sum
              Unit: Count

ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/ECS/ContainerInsights/MemoryUtilized/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/
Type: AWS::CloudWatch::Alarm
Properties:
    AlarmName: ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/ECS/ContainerInsights/MemoryUtilized/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/
    AlarmDescription: This is math expression alarm created and managed by the
        CloudWatch Application Insights. To make changes please go to your
        application's configuration in Application Insights
    Tags:
        - Key: ApplicationInsightsManaged
          Value: "TRUE"
    ActionsEnabled: true
    OKActions: []
    AlarmActions: []
    InsufficientDataActions: []
    Dimensions: []
    EvaluationPeriods: 2
    DatapointsToAlarm: 2
    Threshold: 0.9
    ComparisonOperator: GreaterThanOrEqualToThreshold
    TreatMissingData: ignore
    Metrics:
        - Id: m1
          Label: MemoryUtilized
          Expression: m1_MemoryUtilized/m1_MemoryReserved
        - Id: m1_MemoryUtilized
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: ECS/ContainerInsights
                  MetricName: MemoryUtilized
                  Dimensions:
                      - Name: ClusterName
                        Value: EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
              Period: 300
              Stat: Average
              Unit: Megabytes
        - Id: m1_MemoryReserved
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: ECS/ContainerInsights
                  MetricName: MemoryReserved
                  Dimensions:
                      - Name: ClusterName
                        Value: EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
              Period: 300
              Stat: Average
              Unit: Megabytes

ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/ECS/ContainerInsights/CpuUtilized/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/
Type: AWS::CloudWatch::Alarm
Properties:
    AlarmName: ApplicationInsights/ApplicationInsights-ContainerInsights-ECS_CLUSTER-EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/ECS/ContainerInsights/CpuUtilized/EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg/
    AlarmDescription: This is math expression alarm created and managed by the
        CloudWatch Application Insights. To make changes please go to your
        application's configuration in Application Insights
    Tags:
        - Key: ApplicationInsightsManaged
          Value: "TRUE"
    ActionsEnabled: true
    OKActions: []
    AlarmActions: []
    InsufficientDataActions: []
    Dimensions: []
    EvaluationPeriods: 2
    DatapointsToAlarm: 2
    Threshold: 0.9
    ComparisonOperator: GreaterThanOrEqualToThreshold
    TreatMissingData: ignore
    Metrics:
        - Id: m3
          Label: CpuUtilized
          Expression: m3_CpuUtilized/m3_CpuReserved
        - Id: m3_CpuUtilized
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: ECS/ContainerInsights
                  MetricName: CpuUtilized
                  Dimensions:
                      - Name: ClusterName
                        Value: EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
              Period: 300
              Stat: Average
              Unit: None
        - Id: m3_CpuReserved
          Label: input
          ReturnData: false
          MetricStat:
              Metric:
                  Namespace: ECS/ContainerInsights
                  MetricName: CpuReserved
                  Dimensions:
                      - Name: ClusterName
                        Value: EcsNativeBlueGreenStack-EcsConstructCluster14AE103B-0UD5SYuupUOg
              Period: 300
              Stat: Average
              Unit: None

アプリケーションごとのダッシュボードやアラームを管理したい場合に

Container InsightsでECSクラスターについてCloudWatch Application Insightsを設定した場合にどのようなCloudWatch Alarmが設定されるのか確認してみました。

アプリケーションごとのダッシュボードやアラームを管理したい場合に便利そうですね。

この記事が誰かの助けになれば幸いです。

以上、クラウド事業本部 コンサルティング部の のんピ(@non____97)でした!

この記事をシェアする

FacebookHatena blogX

関連記事