How can I view the ids of failed tasks?

When using Google Cloud batch, I see that several tasks have failed. How can I view the ids of those tasks, so I can look through the logs and determine what caused them to fail?

2 Likes

Ok, this command sort of worked:

gcloud beta batch tasks list --job my-job --project my-project --location us-central1 | grep FAIL

But

  1. It outputs 2 rows, but I have 4 failed tasks

  2. It outputs the warning “ERROR: (gcloud.beta.batch.tasks.list) INVALID_ARGUMENT: pagesize field is invalid. mismatching token page size error: request page size (0) != token page size (500)”

Edit: I see what is going on. For some reason, this is only printing out the first 501 tasks. I needed to do:

gcloud beta batch tasks list --job my-job --project my-project --location us-central1 --page-size 500
2 Likes

Hi @vedantroy-genmo ,

You can view the list of the job’s tasks following

https://cloud.google.com/batch/docs/view-jobs-tasks#list-tasks.

To show which task IDs are failed, for example you can use gcloud command, below is one example:

gcloud batch tasks list \
--job={YOUR_JOB_NAME} \
--location={YOUR_JOB_LOCATION} \
--filter="STATE=FAILED"

Then the command will output the failed task names, and the last field in the name is the task id. Ref: https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs.taskGroups.tasks.

Hope this helps!
Wenyan

2 Likes