[英]How do i send an email alert if my Google Cloud Scheduler job failed?
I have schedule a HTTP call type job using Google Cloud Scheduler.我已经使用 Google Cloud Scheduler 安排了一个 HTTP 调用类型的作业。 How do I send out email alert if the job failed?
如果作业失败,如何发出 email 警报?
I have read the Cloud Scheduler documentation, and google around but the answer is not obvious.我已经阅读了 Cloud Scheduler 文档,并四处搜索,但答案并不明显。 I had also attempted the stackdriver alert policy but can't find the corresponding metrics for the failed log entry.
我也尝试过 stackdriver 警报策略,但找不到失败日志条目的相应指标。
I expect an email notification can be configured to send out if the scheduled job failed.我希望 email 通知可以配置为在计划作业失败时发送。
One way to handle this is to create a new Log-Based Metric with this filter:处理此问题的一种方法是使用此过滤器创建一个新的基于日志的指标:
resource.type="cloud_scheduler_job" severity != INFO
. resource.type="cloud_scheduler_job" severity != INFO
。
Then you can create an alert based on this new metric.然后,您可以根据此新指标创建警报。
I use a workaround to solve my own problem.我使用一种解决方法来解决我自己的问题。
Since my Cloud Scheduler is calling a HTTP call to my Cloud Function.由于我的 Cloud Scheduler 正在调用对我的 Cloud Function 的 HTTP 调用。
I use stack driver to create an alert to monitor my function execution with status code != ok.我使用堆栈驱动程序创建一个警报,以使用状态代码 != ok 监视我的函数执行。 Any time the function execute with failure, an email alert will be send to my inbox.
每当函数执行失败时,都会向我的收件箱发送电子邮件警报。
This for the time being solve my problem.这暂时解决了我的问题。
Nevertheless, perhaps Cloud Scheduler can provide such enhancement to send alert as part of the configuration.尽管如此,也许 Cloud Scheduler 可以提供这样的增强功能来发送警报作为配置的一部分。
thank you.谢谢你。
October 2022: You no longer need to create a metric for this, you can skip that step and create an alert directly from Logs Explorer after entering the query already described: resource.type="cloud_scheduler_job" severity != INFO
2022 年 10 月:您不再需要为此创建指标,您可以跳过该步骤并在输入已描述的查询后直接从日志资源管理器创建警报:
resource.type="cloud_scheduler_job" severity != INFO
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.