简体   繁体   English

如果我的 Google Cloud Scheduler 作业失败,我该如何发送 email 警报?

[英]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.谢谢你。

您可以在 Stackdriver 中使用基于日志的指标以及电子邮件通知,以便在作业失败时获取电子邮件通知。

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.

相关问题 如何将带有图像的测试请求发送到我在 Google Cloud 上部署的 model? - How do I send a test request with an image to my deployed model on Google Cloud? 如何通过谷歌云调度程序调用我的应用程序 api - How to call my app api through google cloud scheduler 如何向 GCP 云调度程序作业添加属性? - How to add attributes to a GCP cloud scheduler job? 我如何在谷歌云平台上跟踪顶点 ai 自定义作业的成本 - how do I track the cost of a vertex ai custom job on google cloud platform 如何让 Google Cloud Logging 以正确的警报级别显示我的 flask + gunicorn 应用程序的日志? - How can I get Google Cloud Logging to show my flask + gunicorn app's logs with the correct alert level? 如何使用 Google Cloud SDK 创建基于日志的指标警报(电子邮件通知)? - How to create log-based-metric alert (email notification) with Google Cloud SDK? 如何设置 Cloud Composer 以发送 email? - How can I setup Cloud Composer to send email? 如何让我的 Google-service.json 在 Google Cloud Plataform 中与 Firestore 一起使用? - How do I get my Google-service.json working with Firestore inside Google Cloud Plataform? 如何在我的 Google Cloud Shell/实例中移动我的 Firebase 目录? - How do I move my Firebase directory in my Google Cloud Shell/Instance? 如何在 python 程序中定义我的 Google Cloud Platform 服务帐户的密钥? - How do I define my Google Cloud Platform service account's key in a python program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM