Afficher l'historique d'une tâche via les événements d'état
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ce document explique comment afficher les événements d'état des tâches et des jobs Batch. Les événements d'état fournissent un historique que vous pouvez utiliser pour analyser les jobs. Ils contiennent souvent des messages d'erreur utiles pour le dépannage.
Chaque job et chacune de ses tâches sont associés à des événements d'état qui sont automatiquement créés par Batch lors de l'exécution du job.
Chacun de ces événements d'état décrit un changement d'état et explique pourquoi cet état a été atteint.
Pour en savoir plus sur les états des jobs et des tâches, consultez Cycle de vie des jobs.
Vous pouvez également configurer une tâche pour qu'elle comporte des événements d'état personnalisés décrivant la progression des exécutables.
Pour en savoir plus sur les événements d'état personnalisés, consultez Configurer des événements d'état personnalisés.
Pour obtenir les autorisations nécessaires pour afficher les jobs et les tâches, demandez à votre administrateur de vous accorder le rôle IAM Lecteur de jobs Batch (roles/batch.jobsViewer) ou Éditeur de jobs Batch (roles/batch.jobsEditor) sur le projet.
Pour en savoir plus sur l'attribution de rôles, consultez la page Gérer l'accès aux projets, aux dossiers et aux organisations.
Les instructions suivantes expliquent comment afficher les événements d'état à l'aide de la consoleGoogle Cloud , de la gcloud CLI et de l'API Batch.
Pour utiliser un langage de bibliothèque cliente, suivez les étapes pour afficher les détails d'un job ou afficher les détails d'une tâche, puis consultez le champ statusEvents[] correspondant.
Afficher les événements d'état d'un job
Console
Pour afficher les événements d'état d'un job dans le projet actuel à l'aide de la consoleGoogle Cloud , procédez comme suit :
Dans la console Google Cloud , accédez à la page Liste des jobs.
Dans la colonne Nom du job, cliquez sur le nom d'un job.
La page "Job Details" (informations sur le job) s'ouvre alors.
L'onglet Détails est ouvert par défaut.
Cliquez sur l'onglet Événements.
gcloud
Pour afficher les événements d'état d'un job à l'aide de gcloud CLI, utilisez la commande gcloud batch jobs describe, puis consultez le champ statusEvents[].
gcloud batch jobs describe JOB_NAME \
--location=LOCATION
Pour afficher les événements d'état d'un job à l'aide de l'API Batch, envoyez une requête GET à la méthode jobs.get, puis consultez le champ statusEvents[].
GET https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs/JOB_NAME
Pour afficher les événements d'état d'une tâche à l'aide de gcloud CLI, utilisez la commande gcloud batch tasks describe, puis consultez le champ statusEvents[].
TASK_INDEX : index de la tâche dont vous souhaitez afficher les détails. Dans un groupe de tâches, l'index de tâche commence à 0 pour la première tâche et augmente de 1 pour chaque tâche supplémentaire. Par exemple, un groupe de tâches contenant quatre tâches possède les index 0, 1, 2 et 3.
TASK_GROUP_NAME : nom du groupe de tâches contenant la tâche dont vous souhaitez afficher les détails. La valeur doit être définie sur group0.
API
Pour afficher les événements d'état d'une tâche à l'aide de l'API Batch, envoyez une requête GET à la méthode tasks.get, puis consultez le champ statusEvents[].
GET https://batch.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs/JOB_NAME/taskGroups/TASK_GROUP_NAME/tasks/TASK_INDEX
TASK_GROUP_NAME : nom du groupe de tâches contenant la tâche dont vous souhaitez afficher les détails. La valeur doit être définie sur group0.
TASK_INDEX : index de la tâche dont vous souhaitez afficher les détails. Dans un groupe de tâches, l'index de tâche commence à 0 pour la première tâche et augmente de 1 pour chaque tâche supplémentaire. Par exemple, un groupe de tâches contenant quatre tâches possède les index 0, 1, 2 et 3.
Étapes suivantes
Pour comprendre les événements d'état de Batch qui décrivent les erreurs, consultez Dépannage.
Si vous souhaitez obtenir un historique plus détaillé de votre job, comme les événements d'état indiquant le début et la fin des exécutables, configurez des événements d'état personnalisés.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/05 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/05 (UTC)."],[[["\u003cp\u003eStatus events in Batch provide a history of state changes for jobs and tasks, including error messages for troubleshooting.\u003c/p\u003e\n"],["\u003cp\u003eBoth jobs and individual tasks within those jobs automatically generate status events that are created by Batch while the job runs and will describe state changes.\u003c/p\u003e\n"],["\u003cp\u003eYou can view job-level status events through the Google Cloud console, gcloud CLI, or Batch API, with the console only showing job-level events.\u003c/p\u003e\n"],["\u003cp\u003eTask-level status events can be accessed via the gcloud CLI or Batch API, and it is done by identifying the task by its index, location, job name, and task group name.\u003c/p\u003e\n"],["\u003cp\u003eCustom status events can be configured for a job to capture more granular progress of runnables.\u003c/p\u003e\n"]]],[],null,["# View a job's history through status events\n\nThis document explains how to view status events for Batch\njobs and tasks. Status events provide a history that you can use to analyze\njobs and often contain useful error messages that you can use for\ntroubleshooting.\n\nEach job and each of its tasks have status events that are automatically\ncreated by Batch while the job runs.\nEach of these status events describe a state\nchange and details about why that state was reached.\nTo learn about job and task states, see\n[Job lifecycle](/batch/docs/create-run-job#lifecycle).\nOptionally, you can also configure a job to have custom status events, which\ndescribe the progress of runnables.\nTo learn more about custom status events, see\n[Configure custom status events](/batch/docs/create-run-job-custom-status-events).\n\nBefore you begin\n----------------\n\n1. If you haven't used Batch before, review [Get started with Batch](/batch/docs/get-started) and enable Batch by completing the [prerequisites for projects and users](/batch/docs/get-started#prerequisites).\n2.\n\n To get the permissions that\n you need to view jobs and tasks,\n\n ask your administrator to grant you the\n\n\n Batch Job Viewer (`roles/batch.jobsViewer`) or Batch Job Editor (`roles/batch.jobsEditor`)\n IAM role on the project.\n\n\n For more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\n You might also be able to get\n the required permissions through [custom\n roles](/iam/docs/creating-custom-roles) or other [predefined\n roles](/iam/docs/roles-overview#predefined).\n\n\u003cbr /\u003e\n\nView status events\n------------------\n\nDifferent status events might appear at the job level\n([`statusEvents[]` field for the job](/batch/docs/reference/rest/v1/projects.locations.jobs#JobStatus.FIELDS.status_events))\nand task level\n([`statusEvents[]` field for each task](/batch/docs/reference/rest/v1/projects.locations.jobs.taskGroups.tasks#TaskStatus.FIELDS.status_events)).\n\nThe following instructions explain how to view status events using the\nGoogle Cloud console, gcloud CLI, and Batch API.\nTo use a client-library language, follow the steps to\n[view the details of a job](/batch/docs/view-jobs-tasks#describe-job) or\n[view the details of a task](/batch/docs/view-jobs-tasks#describe-task)\nand then see the corresponding `statusEvents[]` field.\n\n### View the status events of a job\n\n### Console\n\n| **Note:** The Google Cloud console only lists job-level status events.\n\nTo view the status events of a job in the current project using the\nGoogle Cloud console, follow these steps:\n\n1. In the Google Cloud console, go to the **Job list** page.\n\n [Go to Job list](https://console.cloud.google.com/batch/jobs)\n2. In the **Job name** column, click the name of a job.\n\n The **Job details** page opens.\n\n The **Details** tab is open by default.\n3. Click the **Events** tab.\n\n### gcloud\n\nTo view the status events of a job using the\ngcloud CLI, use the\n[`gcloud batch jobs describe` command](/sdk/gcloud/reference/batch/jobs/describe),\nand then see the `statusEvents[]` field. \n\n gcloud batch jobs describe \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e \\\n --location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name of an existing job.\n\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the [location](/batch/docs/locations)\n where the job exists.\n\n### API\n\nTo view the status events of a job using the\nBatch API, make a `GET` request to the\n[`jobs.get` method](/batch/docs/reference/rest/v1/projects.locations.jobs/get),\nand then see the `statusEvents[]` field. \n\n GET https://batch.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/jobs/\u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the\n [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects)\n of the current project.\n\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the [location](/batch/docs/locations)\n where the job exists.\n\n- \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name of an existing job.\n\n### View the status events of a task\n\n### gcloud\n\nTo view the status events of a task using the gcloud CLI, use the\n[`gcloud batch tasks describe` command](/sdk/gcloud/reference/batch/tasks/describe),\nand then see the `statusEvents[]` field. \n\n gcloud batch tasks describe \u003cvar translate=\"no\"\u003eTASK_INDEX\u003c/var\u003e \\\n --location=\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e \\\n --job=\u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e \\\n --task_group=\u003cvar translate=\"no\"\u003eTASK_GROUP_NAME\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eTASK_INDEX\u003c/var\u003e: the index of the task that you want to view\n the details of. In a task group, the task index starts at 0 for the first\n task and increases by 1 with each additional task. For example, a task\n group that contains four tasks has the indexes `0`, `1`, `2`, and `3`.\n\n- \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name of an existing job.\n\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the [location](/batch/docs/locations) where\n the job exists.\n\n- \u003cvar translate=\"no\"\u003eTASK_GROUP_NAME\u003c/var\u003e: the name of the task group that\n contains the task that you want to view the details of. The value must be\n set to [`group0`](/batch/docs/get-started#restrictions).\n\n### API\n\nTo view the status events of a task using the Batch API,\nmake a `GET` request to the\n[`tasks.get` method](/batch/docs/reference/rest/v1/projects.locations.jobs.taskGroups.tasks/get),\nand then see the `statusEvents[]` field. \n\n GET https://batch.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/jobs/\u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e/taskGroups/\u003cvar translate=\"no\"\u003eTASK_GROUP_NAME\u003c/var\u003e/tasks/\u003cvar translate=\"no\"\u003eTASK_INDEX\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the\n [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects)\n of the current project.\n\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the [location](/batch/docs/locations)\n where the job exists.\n\n- \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e: the name of an existing job.\n\n- \u003cvar translate=\"no\"\u003eTASK_GROUP_NAME\u003c/var\u003e: the name of the task group that\n contains the task that you want to view the details of. The value must be\n set to [`group0`](/batch/docs/get-started#restrictions).\n\n- \u003cvar translate=\"no\"\u003eTASK_INDEX\u003c/var\u003e: the index of the task that you want to view\n the details of. In a task group, the task index starts at 0 for the first\n task and increases by 1 with each additional task. For example, a task\n group that contains four tasks has the indexes `0`, `1`, `2`, and `3`.\n\nWhat's next\n-----------\n\n- To understand status events from Batch that describe errors, see\n [Troubleshooting](/batch/docs/troubleshooting).\n\n- If you want a more detailed history for your job, such as status events\n for when runnables start and end,\n [configure custom status events](/batch/docs/create-run-job-custom-status-events).\n\n- Learn how to\n [analyze a job by using logs](/batch/docs/analyze-job-using-logs)."]]