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?

Lambdaがトリガーされた際に渡されるデータの中身を見てみた

Last updated at Posted at 2025-05-10

概要

CloudwatchLogsとEventBridgeによってLambdaがトリガーされた際に関数には、
どんなもデータが渡されているのかみていきます。

構成

以下のようなリソース群を作成していきます。
Lambdaのトリガーの際に連携されたデータを送信先のCloudWatchLogsで確認していきます。

20250322.drawio.png

構築

練習がてらCludFormationで構築していきます。
多いので以下にまとめています。

上記をS3に配置してCloudFormation実行とLambda関数にコードを参照させています。

ログのプッシュ

サブスクリプションフィルタには「Error」の単語が含まっていた際に、Lambda関数を実行するようにしています。それを含めてログをロググループを実行していきます。

aws logs put-log-events --log-group-name sender-log-group --log-stream-name sender-log-stream --log-events timestamp=$(date +%s%3N),message="Error test log"

結果

以下のような形式で送られてくるようです。

{
    "messageType": "DATA_MESSAGE",
    "owner": "AWSアカウントID",
    "logGroup": "送信元ロググループ名",
    "logStream": "送信元ロググループのログストリーム名",
    "subscriptionFilters": [
        "送信元ロググループのサブスクリプションフィルター名"
    ],
    "logEvents": [
        {
            "id": "ログイベントID(実際はランダムな数列が入っている)",
            "timestamp": 1746864558130,
            "message": "Error test log"
        }
    ]
}

今回の検証は以上になります。
ログ監視の設計構築の助けになれば幸いです。

お疲れ様でした。

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?