LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Wednesday, February 20, 2019

Lambda functionの実行ログを見たい(CloudWatch)


API GatewayのendpointにアクセスしてFunctionを実行したあと
そのログを見たい


「Monitoring」をクリックして


「View logs in CloudWatch」をクリックすると


ログが出ている

ログをクリックすると中身を見ることができる

Lambda functionの中で、console.log("出したいログ")と書くとここに出せるようだ


補足

こんなエラーが出てログを見れないことがありました
「There was an error loading Log Streams. Please try again by refreshing this page.」と書かれていて、ページを読み込み直しても解決しない、、


試して解決した方法を以下に書き残しておきます


「Search Log Group」が強調されているのでクリックしてみると
Log group not found
The log group /aws/lambda/myFunction could not be found. Check if it was correctly created and retry.
というエラーが出て、どうやらロググループが見つからないらしい

correctly createdの確認方法はわかりませんが、retryしても同じでした
Log groupがないなら作ればよいのかなと思い
勘を頼りに左のメニューを開いて「Logs」をクリックしてみます

Log Groupに対象のfunctionが見つからない

「Action」の中を見ると「Create log group」があるので選択してみます

とりあえず「myFunctionLog」と名前をつけて「Create log group」をクリックする

一番下にLog Groupが作成されました

このあと再度API Gatewayのendpointにアクセスするとログが出ました


参考

Node.js の AWS Lambda 関数ログ作成
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/nodejs-prog-model-logging.html

AWS Lambda の Amazon CloudWatch ログへのアクセス
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/monitoring-functions-logs.html

Lambda logs not visible : "There was an error loading Log Streams"
https://forums.aws.amazon.com/message.jspa?messageID=623472

Latest post

スプレッドシートA列にある複数のテキストをスライドに追加したい(Google Apps Script)

今回Google Apps Scriptでやりたいこと GoogleスプレッドシートA列にある複数の値を取得して Googleスライドに渡して 図形オブジェクトのテキストとして追加したい ① スプレッドシートのA列に値を入れておく ② Code.gsのinsertNewShape...