Apps Script公式リファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2019年2月20日水曜日

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

Google Apps Scriptの障害時はIssueTrackerを見てみる - Incidents for Apps Script are reported on Issue Tracker

IssueTracker > Apps Script issues https://issuetracker.google.com/savedsearches/566234 Google Apps Scriptの障害時は IssueTracker に課題が上がっていることが...