您如何提醒 Alexa 技能的错误和警告?

How do you alert on errors and warnings for an Alexa skill?

我正在尝试为连接到 Alexa 技能的 AWS Lambda 函数 (node.js 8.10) 设置日志记录。我注意到 CloudWatch 可以轻松 alert on errors or route to alternate processing queues in the case where the lambda returns a proper error response, and you can use metric filters to automate searching through log files 并针对不同的文本发出警报。

我注意到我的堆栈的两个属性使用这个变得复杂:

考虑到这一点,我的问题是:

我们最终将 Winston 添加到我们的 Lambda 中,并使用它为我们的日志提供可解析的格式。

从那里,我们设置了一个 CloudWatch 指标过滤器来寻找以下模式:

[logLevel="error:", ...]

然后在匹配的情况下将标志设置为 1。

然后,我们设置了一个 CloudWatch 警报,以在设置标志时触发发送到 SNS 主题的电子邮件。我们没有在生成的电子邮件中获得具体的日志,但我们有足够的信息来登录和检查日志。