0
0

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 3 years have passed since last update.

ターミナルからCloudWatch logsをTailする方法

Last updated at Posted at 2021-01-13

はじめに

めちゃめちゃ便利なツールを教えていただいたので、共有したいと思います。

検証用にECSのコンテナから吐き出されたログをCloudWatch logsに出力し確認することがあると思います。
その時、CloudWatch logsにStream出力されたログを、itermなどのターミナルから確認したいという方におすすめのツールを紹介します。

AWSlogs

awslogsというツールを使用することで、この願いが叶います。

インストール

  • pipで入れたい人
pip install awslogs
  • brewで入れたい人
brew install awslogs

awslogsのサブコマンド

サブコマンド 説明
groups CloudWatch Logsのロググループ名を表示
streams CloudWatch Logsのストリーム名を表示
get CloudWatch Logsのストリームに発生したイベントを表示

オプション

  • -w オプション
    このオプションは、ログを表示し続けます。

  • -G オプション
    ロググループ名を省略して表示させます。

  • -S オプション
    ストリーム名を省略して表示させます。

  • --timestamp オプション
    ストリームにイベントが発生した時間を表示します。

  • -s オプション
    ストリームにイベントが発生した時間以降のログを表示させます。

上記を踏まえ、tailする時のコマンドはこれ

awslogs get [log_group_name] -w -s 10m -G -S --timestamp
意味は、10分前以降の指定したロググループのイベントをtailし、ストリーム名、ロググループ名を省略し、ストリームにイベントが発生した時間は表示するという意味です。

awslogs get ??? -w -s 10m -G -S --timestamp
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?