I was searching for the same solution to monitoring GKE Cronjobs and found this method:
By utilizing GCP's Log Alert feature, we were able to use this following Log query to be notified when a Cronjob's job is considered failed
Log Based Alert Doc
resource.labels.cluster_name="CLUSTER_NAME"
resource.type="k8s_cluster"
jsonPayload.source.component="cronjob-controller"
jsonPayload.reason="SawCompletedJob"
"status: Failed"
The sample log is like this
{
"insertId": "sb6oijf4yi39m",
"jsonPayload": {
"type": "Normal",
"reportingComponent": "",
"source": {
"component": "cronjob-controller"
},
"lastTimestamp": "2023-04-19T12:05:53Z",
"metadata": {
"uid": "0efad02d-c441-4964-b048-496552ecc572",
"namespace": "default",
"managedFields": [
{
"apiVersion": "v1",
"time": "2023-04-19T12:05:53Z",
"manager": "kube-controller-manager",
"fieldsType": "FieldsV1",
"operation": "Update",
"fieldsV1": {
"f:count": {},
"f:reason": {},
"f:firstTimestamp": {},
"f:type": {},
"f:source": {
"f:component": {}
},
"f:involvedObject": {},
"f:lastTimestamp": {},
"f:message": {}
}
}
],
"resourceVersion": "47727088",
"creationTimestamp": "2023-04-19T12:05:53Z",
"name": "CRONJOB_NAME.1757548d9eb51a26"
},
"message": "Saw completed job: CRONJOB_NAME-28031760, status: Failed",
"kind": "Event",
"eventTime": null,
"involvedObject": {
"apiVersion": "batch/v1",
"namespace": "default",
"kind": "CronJob",
"name": "CRONJOB_NAME",
"uid": "6c43108b-14d6-11ea-ac1e-42010af00026",
"resourceVersion": "1286547540"
},
"reportingInstance": "",
"apiVersion": "v1",
"reason": "SawCompletedJob"
},
"resource": {
"type": "k8s_cluster",
"labels": {
"cluster_name": "REDACTED",
"project_id": "REDACTED",
"location": "asia-east1-a"
}
},
"timestamp": "2023-04-19T12:05:53Z",
"severity": "INFO",
"logName": "projects/REDACTED/logs/events",
"receiveTimestamp": "2023-04-19T12:05:58.075764494Z"
}