How do I troubleshoot health check failures for Amazon ECS tasks on Fargate?

Amazon Web Services
30 May 202407:35

Summary

TLDRこのビデオでは、AWSのテクニカルアカウントマネージャーであるモニカが、Amazon Elastic Container Service (ECS) におけるヘルスチェックの失敗をトラブルシューティングする方法を紹介しています。ECS タスクのヘルスチェックに関連するエラーが発生した場合、AWS Management コンソールからECSクラスターを選択し、サービス設定、セキュリティグループの確認、CPU使用率の監視、ヘルスチェックのタイムアウト値の設定、ロードバランサーの設定などを通じて問題を特定し、解決策を提供しています。また、504エラーが発生した場合には、接続タイムアウトやネットワークアクセスコントロールリストの問題をチェックし、アプリケーションログとCloudWatchログを確認して問題を特定することが推奨されています。

Takeaways

  • 🔍 エラーが発生した場合は、AWS Managementコンソールにログインして特定のトラブルシューティングステップに従う必要があります。
  • 📍 ECSクラスターとサービスを選択し、タスク定義のJSONタブでコンテナのポート設定を確認することが重要です。
  • 🛡️ セキュリティグループの受信ルールを確認し、ロードバランサーからのトラフィックが許可されていることを確認します。
  • 🚫 高CPU使用率がアプリケーションの応答を妨げ、ヘルスチェック失敗につながることに注意が必要です。
  • 🕒 ヘルスチェックのタイムアウト値よりもアプリケーションのウォームアップに時間がかかる場合は、ヘルスチェックリスク期間を設定することが推奨されます。
  • 🔄 サービス定義パラメータとしてヘルスチェックリスク期間を指定することで、サービススケジューラに失敗したロードバランサーヘルスチェックを無視させることができます。
  • 🗂️ タスクのログを確認し、アプリケーションエラーやバックエンドデータベースへの接続の問題を特定します。
  • 🚫 504エラーを受け取った場合、ロードバランサーがターゲットに接続できなかったり、アイドルタイムアウト期間が経過したためにターゲットが応答しなかったりする可能性があります。
  • 🔄 タスク定義のヘルスチェックコマンドが正しい構文で正しく渡されているか確認することが重要です。
  • 🔧 Amazon CloudWatchのログを確認し、さらにトラブルシューティングを行うことができます。
  • 💻 ECSタスクがAmazon EC2で実行されている場合、SSHを使用してEC2インスタンスに接続してトラブルシューティングを進めることができます。

Q & A

  • AWSのElastic Container Service (ECS) とは何ですか?

    -AWSのElastic Container Service (ECS)は、コンテナを簡単に実行し管理するためのフルマネージドコンテナオーケストレーションサービスです。

  • AWS Managementコンソールにログインし、リージョンを選択する必要がある理由は何ですか?

    -リージョンを選択することにより、リソースが配置されている地理的な場所を指定し、適切なデータセンターからサービスにアクセスできます。

  • ECSクラスターとは何で、トラブルシューティングにどのように役立ちますか?

    -ECSクラスターは、ECSタスクを実行するための一連のEC2インスタンスのグループです。トラブルシューティングでは、クラスターの構成と状態を確認して問題を特定するのに役立ちます。

  • タスク定義とは何で、Jsonタブで何を確認する必要がありますか?

    -タスク定義は、ECSタスクが実行される際に必要なすべてのパラメータを含むAmazon ECSのリソースです。Jsonタブでは、コンテナのポート構成を確認する必要があります。

  • セキュリティグループのインバウンドルールを確認する理由は何ですか?

    -セキュリティグループのインバウンドルールを確認することで、コンテナが割り当てられたポートでの受信トラフィックが許可されているかを確認できます。

  • 高CPU使用率がアプリケーションにどのような影響を与える可能性がありますか?

    -高CPU使用率はアプリケーションが応答不能になり、ターゲットグループのヘルスチェックに失敗する原因となる可能性があります。

  • ヘルスチェックリスク期間とは何で、どのように設定するのですか?

    -ヘルスチェックリスク期間は、タスクが開始された後、事前に定義された期間 동안に失敗したロードバランサーのヘルスチェックを無視するようにサービススケジューラに指示するAmazon ECSサービス定義パラメータです。

  • ECSサービスのターゲットグループに関連するセキュリティグループの設定を確認する必要性はありますか?

    -はい、セキュリティグループの設定が正しくない場合、ロードバランサーはターゲットグループに登録されているタスクを正常でないとマークし、サービススケジューラはタスクをターゲットグループから登録解除します。

  • 504エラーが発生する一般的な理由は何ですか?

    -504エラーは、ロードバランサーがターゲットに接続を確立できなかったり、接続タイムアウトが切れた前にターゲットからの応答がない場合に発生します。

  • アプリケーションログとAmazon CloudWatchログを確認する理由は何ですか?

    -アプリケーションログとAmazon CloudWatchログを確認することで、アプリケーションのエラーや異常を特定し、トラブルシューティングに役立てることができます。

  • AWS Fargateで実行されるタスクをトラブルシューティングする際に、ECSタスクをAmazon EC2で実行し、SSHで接続する理由は何ですか?

    -AWS Fargateは管理されたサービスであるため、基盤のホストに直接アクセスすることはできません。EC2インスタンスにタスクを実行し、SSHで接続することで、より詳細なトラブルシューティングが可能です。

Outlines

00:00

😀 ECSサービスのヘルスチェック失敗トラブルシューティング

この段落では、AWSのテクニカルアカウントマネージャーであるモニカが、Amazon Elastic Container Service (ECS) におけるヘルスチェック失敗のトラブルシューティング方法を紹介しています。ECSクラスターとサービスを選択し、コンフィギュレーションとネットワークタブからタスク定義を開き、JSONタブでコンテナのポート設定を確認することが説明されています。また、セキュリティグループのインバウンドルールの確認、CPU使用率のモニタリング、ヘルスチェックのタイムアウト値の設定、サービス定義パラメータでのヘルスチェックリスク期間の指定、ロードバランサーのヘルスチェックポートの設定確認など、様々なトラブルシューティングステップが詳述されています。さらに、アプリケーションログの確認やバックエンドデータベースへの接続確認など、504エラー時の対処法も触れられています。

05:02

😀 タスクログの確認とトラブルシューティングの進め方

2つ目の段落では、ヘルスチェックに失敗するコンテナのトラブルシューティング手順が紹介されています。まず、AWS Managementコンソールにログインし、ECSクラスターとサービスを選択し、ターゲットグループのヘルスチェックタブで応答タイムアウト値を確認することがポイントです。次に、コンテナに渡されるコマンドの正しさと構文を確認し、アプリケーションログとAmazon CloudWatchログをチェックすることが推奨されています。さらに、クラスターからECSサービスを選択し、トラブルシューティング対象のタスクを選択し、ログタブからタスクログを確認する方法が説明されています。必要であれば、Amazon EC2インスタンスにSSHで接続し、詳細なトラブルシューティングを行うことも可能です。このセクションでは、ヘルスチェック失敗時の具体的な対処法が詳しく解説されています。

Mindmap

Keywords

💡AWS

AWSはAmazon Web Servicesの略で、クラウドコンピューティングサービスを提供するAmazonの部門です。このビデオではAWSのサービスの一つであるECS(Elastic Container Service)を使用して、AWS上で実行されるコンテナサービスの問題をトラブルシューティングする方法が説明されています。

💡ECS

Elastic Container Service(ECS)は、AWSが提供するコンテナオーケストレーションサービスです。コンテナ化されたアプリケーションを簡単に管理し、スケーリングすることができます。ビデオではECS上で実行されるタスクのヘルスチェック失敗を解決する方法について説明されています。

💡ヘルスチェック失敗

ヘルスチェック失敗とは、ロードバランサーがターゲット(コンテナ)の状態を確認するプロセスで、ターゲットが正常でないと判断された場合に発生する状態です。ビデオでは、ECS上で実行されるタスクにおいてこの問題をトラブルシューティングする手順が紹介されています。

💡セキュリティグループ

セキュリティグループは、AWS上で仮想ファイアウォールの機能を提供し、インバウンドとアウトバウンドのトラフィックを制御します。ビデオでは、セキュリティグループのインバウンドルールがコンテナへのトラフィックに影響を与える例として説明されています。

💡CPU

CPUはCentral Processing Unitの略で、コンピュータの中心となる処理装置です。ビデオでは、CPUの使用率が高くアプリケーションが応答しなくなることがあると触れており、ヘルスチェック失敗の原因の一つとして挙げられています。

💡ターゲットグループ

ターゲットグループは、ロードバランサーがトラフィックをルーティングする対象となる一連のリソース(ECSタスクなど)を定義するAWSの機能です。ビデオでは、ターゲットグループの設定がヘルスチェック失敗に関連していると説明されています。

💡ヘルスチェックリスク期間

ヘルスチェックリスク期間は、ECSサービス定義パラメーターで指定される期間で、タスクが開始されてから一定時間はヘルスチェックの失敗を無視するようにサービススケジューラに指示します。ビデオでは、アプリケーションのウォームアップに時間がかかる場合にこの設定を使用する例が紹介されています。

💡トラフィックポート

トラフィックポートとは、アプリケーションが通信を行うために使用するポートのことです。ビデオでは、セキュリティグループでトラフィックポート(例ではポート80)に対するインバウンドトラフィックを許可する必要があると説明されています。

💡アプリケーションログ

アプリケーションログは、アプリケーションの動作状況を記録したログファイルです。ビデオでは、アプリケーションログを確認することでトラブルシューティングを行う方法が紹介されており、ログからエラーを特定することができると説明されています。

💡504エラー

504エラーは、ゲートウェイタイムアウトエラーのことで、サーバーが別のサーバーからの応答をタイムアウトまでに受け取れなかった場合に発生します。ビデオでは、504エラーが発生する理由としていくつかの例が挙げられており、その解決方法についても説明されています。

Highlights

Introduction to troubleshooting health check failure for Amazon Elastic Container Service (ECS) on AWS Fargate.

Step-by-step guide on how to navigate the AWS Management Console for ECS troubleshooting.

Explanation of ECS cluster selection and task definition inspection for troubleshooting.

Importance of checking security group inbound rules for container port mappings.

The impact of high CPU on application unresponsiveness and potential health check errors.

Monitoring CPU and memory utilization through the health and metrics tab.

How to set a health check grace period for ECS service definition to handle warm-up times.

Instructions on editing the health check grace period through the ECS service update.

Verification of the health check port configuration for load balancer integration.

Consequences of incorrect health check port configuration on task health status.

Process to confirm the health check port and path settings in the load balancer.

Advice on checking application logs for errors and backend database connectivity.

Understanding the causes and troubleshooting steps for a 504 error in ECS.

Guidance on navigating through the AWS Management Console to address 504 errors.

Importance of setting the correct response timeout value for health checks.

Troubleshooting steps for containers failing the health check due to incorrect command syntax.

How to check task logs in the AWS Management Console for further diagnostics.

Alternative troubleshooting method using Amazon EC2 instances and SSH.

Conclusion and thanks for watching, highlighting the end of the ECS troubleshooting guide.

Transcripts

play00:00

[Music]

play00:01

[Applause]

play00:02

[Music]

play00:07

hello I'm a Monica a technical account

play00:09

manager here at the AWS office in Boston

play00:12

today I'm going to show you how to

play00:14

troubleshoot health check failure for

play00:16

the Amazon elastic container service

play00:18

task on ews farget let's get started if

play00:22

you receive either of these

play00:28

errors try this troubleshooting steps

play00:31

after logging into the AWS Management

play00:34

console select the region navigate to

play00:37

the elastic container service in

play00:41

console select the ECS cluster that you

play00:44

are

play00:45

troubleshooting select the ECS

play00:49

service go to configuration and

play00:51

networking tab go to task definition

play00:55

under a service configuration and open

play00:57

in new tab

play01:02

select the Json Tab and note down the

play01:04

container Port configuration in my case

play01:07

I'm using the port

play01:11

80 let's go back to the ECS service

play01:14

configuration and networking page select

play01:17

the security group associated with your

play01:20

container from the network configuration

play01:22

in Security Group check the inbound

play01:25

rules if your container is mapped to the

play01:28

port 80 confirm that your container

play01:30

Security Group allows the inbound

play01:32

traffic on a port 80 for the Lord

play01:36

balancer High CPU can make your

play01:38

application unresponsive and that can

play01:41

also result in fire2 error you can

play01:43

monitor the CPU and memory utilization

play01:46

under the health and Metric tab if your

play01:49

application needs more time to warm up

play01:51

than the timeout value specified in the

play01:53

health check settings of the target

play01:54

group then specify a health check risk

play01:57

period as an Amazon ECS service

play01:59

definition parameter this instruct the

play02:02

service schedular to ignore any failed

play02:04

load balancer H check for a predefined

play02:06

time period after a task has been

play02:09

instated this is only valid if your

play02:12

servic is configured to use the load

play02:14

balancer if your service has a load

play02:16

balance defined and you do not specify a

play02:20

h check grace period value then the

play02:22

default value of zero is used to edit

play02:26

the value click on update service

play02:30

go to load balancing and adjust the he

play02:33

check grace

play02:36

period then click on update I'm not

play02:40

going to change so clicking on the

play02:42

cancel

play02:43

button now let's confirm that the heal

play02:46

check Port value for your load balance

play02:49

or health is configured correctly if

play02:51

this port is not configured correctly

play02:54

then your load balancer marks the task

play02:57

that is registered as a Target in the

play02:59

target group as unhealthy and the

play03:01

service scheduler then deregister the

play03:03

task for the Target group go to task tab

play03:08

select running task select Network

play03:11

binding on a container details the hche

play03:15

port must be configured to use the host

play03:17

Port value for the container in your

play03:20

service task definition that you're

play03:22

using with the H Che choose ECS

play03:28

service select the Target group

play03:30

associated with ECS

play03:33

service go to the health check

play03:36

tab make sure that heal check port and

play03:39

heal check path are configured correctly

play03:42

make sure that you use the traffic port

play03:44

or predicated health check Port if you

play03:46

have configured

play03:47

that for further troubleshooting check

play03:50

your application logs for the

play03:52

application error make sure that your

play03:54

backend database is connected

play03:56

successfully this assume that your

play03:58

application is running as a set of task

play04:00

launched by the ECS on thews forget it

play04:03

also assume that your application cannot

play04:05

communicate with Amazon relational

play04:07

database

play04:10

service if you receive a 504 error such

play04:13

as

play04:16

this you can receive a 504 error for any

play04:19

of these reasons your load balancer

play04:21

failed to establish the connection to

play04:23

the Target before the connection time

play04:25

out expired your load balancer establish

play04:29

the connection to the Target but the

play04:30

target did not response before the idle

play04:33

timeout period elapsed the network

play04:36

access control list for your subnet did

play04:38

not allow the traffic from the target to

play04:40

the load balancer nodes on the FML

play04:43

ports try this troubleshooting steps

play04:46

after logging into the AWS Management

play04:48

console select the region and then

play04:51

navigate to the elastic container

play04:52

service in

play04:55

console select the ECS cluster that you

play04:58

are troubleshooting

play05:02

select the ECS

play05:04

service select the target group

play05:06

associated with ECS

play05:09

service go to the health checks tab make

play05:13

sure that the response timeout value is

play05:15

set correctly the response timeout is

play05:17

the amount of the time that your

play05:19

container has to return a response to

play05:22

the health check request if this value

play05:24

is lower than the amount of the time

play05:26

required for a response then the health

play05:28

check fails

play05:31

if you receive the following error the

play05:33

containers in your task are using the H

play05:35

check that your service cannot

play05:39

pass try this troubleshooting steps

play05:42

confirm that the command that you are

play05:43

passing to the container is correct and

play05:46

has the right syntax check your

play05:48

application logs and Amazon Cloud watch

play05:50

logs if the task has been running for a

play05:53

while after logging into the AWS

play05:56

Management console select the region

play05:58

navigate to the elastic container

play06:00

service in

play06:02

console select task definition from the

play06:05

left side of the navigation page select

play06:08

the task definition that you are

play06:14

troubleshooting go to the Json tab look

play06:16

for the health check and then confirm

play06:19

that the command that you are passing to

play06:20

the container is correct and has the

play06:22

right

play06:23

syntax now let's see how to check the

play06:26

task logs for the further

play06:28

troubleshooting select the cluster from

play06:30

the left side of the navigation page

play06:32

select the ECS cluster that you are

play06:35

troubleshooting select the ECS

play06:38

service navigate to task

play06:41

Tab and select the task that you are

play06:46

troubleshooting go to logs tab you can

play06:49

view task logs here or you can click

play06:52

view logs in cloudwatch which opens the

play06:54

associated log stream in the cloudwatch

play06:57

console you cannot access the underlying

play07:00

host because forget is managed by DWS

play07:03

for further troubleshooting launch your

play07:06

Amazon is task in Amazon ec2 then

play07:09

connect to your ec2 instance using

play07:12

SSH so now you know how to troubleshoot

play07:15

he check failures on ECS task on ews

play07:18

forget thanks for watching and happy

play07:21

cloud computing from all of us here at

play07:23

thews

play07:25

[Applause]

play07:27

[Music]

play07:32

[Music]

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
AWSECSヘルスチェックトラブルシューティングクラウドコンピューティングセキュリティグループターゲットグループロードバランサーアプリケーションログCPUモニタリング
هل تحتاج إلى تلخيص باللغة الإنجليزية؟