How do i send an email alert if my Google Cloud Scheduler job failed?
Asked Answered
M

4

10

I have schedule a HTTP call type job using Google Cloud Scheduler. How do I send out email alert if the job failed?

I have read the Cloud Scheduler documentation, and google around but the answer is not obvious. I had also attempted the stackdriver alert policy but can't find the corresponding metrics for the failed log entry.

I expect an email notification can be configured to send out if the scheduled job failed.

Moorhead answered 2/4, 2019 at 10:12 Comment(0)
C
8

One way to handle this is to create a new Log-Based Metric with this filter:

resource.type="cloud_scheduler_job" severity != INFO.

Then you can create an alert based on this new metric.

Chloropicrin answered 14/12, 2019 at 20:3 Comment(2)
It looks like this has changed, any chance @Chloropicrin that you know how to do this in Metrics Explorer now?Communion
More info, I have tried, it looks like its now under log_metrics, but when I do severity != INFO I get nothing, when I know I have had failed jobs recentlyCommunion
M
3

I use a workaround to solve my own problem.

Since my Cloud Scheduler is calling a HTTP call to my Cloud Function.

I use stack driver to create an alert to monitor my function execution with status code != 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.

thank you.

Moorhead answered 3/4, 2019 at 1:6 Comment(1)
Agreed. This should be part of the configuration within the GCP console.Asp
J
1

You can use log-based metrics in Stackdriver along with email notifications to get email notifications when your job fails.

Jara answered 3/4, 2019 at 17:24 Comment(0)
M
1

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

Manducate answered 10/10, 2022 at 9:58 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.