LoginSignup
0
0

【自分用メモ】AWS ECSタスクログの見方

Posted at

はじめに

業務でECSタスクを手動で動かす機会があり、その実行したタスクのログをみる際にコンソールの中で迷子になったため、忘れないよう自分用のメモです。

まずはECSタスクを実行する

ECSでHelloWorldが手軽にタスクを実行できそうだったので以下を参考にやってみる。

今回使うDockerイメージ

ターミナルで実行してみる

以下のような実行結果が返ってきます。

docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
70f5ac315c5a: Pull complete
Digest: sha256:dcba6daec718f547568c562956fa47e1b03673dd010fe6ee58ca806767031d1c
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

タスクを設定

AWSコンソール>ECSコンソール>タスク定義より以下画面へ遷移。
タスク定義名を入力。
スクリーンショット 2023-09-03 12.14.57.png
各種設定値を入力
詳細は以下

  • 設定値
    • 起動タイプ: Fargate
    • タスクサイズ
      • CPU: 1 vCPU
      • メモリ: 2GB

スクリーンショット 2023-09-03 12.19.46.png

クラスターの作成

AWSコンソール>ECSコンソール>クラスターより以下画面へ遷移。
クラスター名を入力し作成。
スクリーンショット 2023-09-03 12.27.48.png

ECSタスクの実行

先ほど同様、AWSコンソール>ECSコンソール>タスク定義より以下画面へ遷移。
以下の画像のように作成したタスクを選択した状態でデプロイ>タスクの実行を押下。
スクリーンショット 2023-09-03 12.40.26.png

既存のクラスターより「クラスターの作成」にて作成したクラスターを選択して起動タイプを押し、Fargeteを選択。
他の設定は変えずに「作成」を押下。
スクリーンショット 2023-09-03 12.39.37.png

タスクの欄よりタスクが実行されているのがわかる。
スクリーンショット 2023-09-03 12.46.48.png

本題 タスクのログを見る

タスクの実行が確認できた画面のタスクのタブよりタスクのハッシュ値のリンクよりタスクの詳細画面へ遷移。
ログのタブを開くとタスクログを確認することができる。
スクリーンショット 2023-09-03 12.47.16.png

停止したタスクログは以下のように「すべてのタスク」より停止したタスクも表示させ確認できる。
スクリーンショット 2023-09-03 12.53.36.png

おまけ

タスクログは1時間で消えてしまうらしい、、
過去のログはCloudTrailで確認できるとのこと。(以下記事より)

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