Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ce document explique comment créer des workflows basés sur des événements déclenchés par des changements d'état dans vos jobs Dataflow.
Par exemple, votre workflow peut :
Envoyer une alerte à un ingénieur d'astreinte en cas d'échec d'un job critique.
Notifier les utilisateurs lorsqu'un job par lot est terminé, ou démarrer un autre job Dataflow.
Nettoyer les ressources utilisées par un job, telles que les buckets Cloud Storage.
Présentation
Eventarc est un service Google Cloud qui peut écouter des événements provenant d'autres services et les acheminer vers différentes destinations.
Lorsque vous exécutez un job Dataflow, celui-ci passe par différents états, tels que JOB_STATE_QUEUED, JOB_STATE_RUNNING et JOB_STATE_DONE.
L'intégration de Dataflow à Eventarc vous permet de déclencher une action lorsqu'un job change d'état.
Eventarc étant un service géré, vous n'avez pas besoin de provisionner ou de gérer l'infrastructure sous-jacente.
Avant de commencer
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Pour utiliser l'API Eventarc, votre projet doit disposer d'un quota suffisant. En outre, le compte de service associé au déclencheur Eventarc doit disposer des autorisations appropriées.
Choisir la destination de l'événement
Choisissez une destination d'événement à laquelle l'événement sera envoyé. La destination détermine l'étape suivante de votre workflow.
Exemple :
Pour envoyer une alerte par SMS, vous pouvez utiliser Cloud Run Functions pour créer un déclencheur HTTP autonome.
Pour un workflow plus complexe, vous pouvez utiliser Workflows.
Si votre pipeline Dataflow fait partie d'une solution plus importante qui s'exécute sur Google Kubernetes Engine, le déclencheur peut acheminer l'événement vers un service GKE exécuté dans votre cluster.
Vous pouvez éventuellement filtrer les événements par ID de job Dataflow. Par exemple, vous pouvez sélectionner des ID de job correspondant à une expression régulière. Pour en savoir plus, consultez la page Comprendre les formats de chemin d'accès.
Traiter les événements
Les données d'événement décrivent le job Dataflow au moment où l'événement a été déclenché. La charge utile est semblable au type de ressource Job, avec les champs steps, pipeline_description et transform_name_mapping omis. De plus, en fonction de l'état du job, certains champs peuvent ne pas être présents.
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/04 (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/04 (UTC)."],[[["\u003cp\u003eThis guide details the process of creating event-driven workflows that are activated by state changes in Dataflow jobs, enabling actions like sending alerts, starting other jobs, or cleaning up resources.\u003c/p\u003e\n"],["\u003cp\u003eEventarc, a managed Google Cloud service, is used to listen for Dataflow job state changes, such as \u003ccode\u003eJOB_STATE_QUEUED\u003c/code\u003e, \u003ccode\u003eJOB_STATE_RUNNING\u003c/code\u003e, or \u003ccode\u003eJOB_STATE_DONE\u003c/code\u003e, and route these events to various destinations without needing infrastructure management.\u003c/p\u003e\n"],["\u003cp\u003eYou can select different event destinations for your workflows, including Cloud Run for sending SMS alerts, Workflows for more complex setups, or Google Kubernetes Engine (GKE) for integrating with services running in your cluster.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating a trigger for Dataflow job state changes, you have the option to filter events by Dataflow job ID, allowing for targeted actions based on specific job identifiers or patterns.\u003c/p\u003e\n"],["\u003cp\u003eThe event data provided contains details about the Dataflow job at the time of the state change, including its ID, project, name, current state, and timestamps, facilitating informed decision-making in your workflow.\u003c/p\u003e\n"]]],[],null,["# Use Eventarc to manage Dataflow jobs\n\nThis document describes how to create event-driven workflows triggered by state\nchanges in your Dataflow jobs.\n\nFor example, your workflow might:\n\n- Send an alert to an on-call engineer if a critical job fails.\n- Notify users when a batch job completes, or start another Dataflow job.\n- Clean up resources used by a job, such as Cloud Storage buckets.\n\nOverview\n--------\n\n[Eventarc](/eventarc/docs) is a Google Cloud service that can\nlisten to events from other services and route them to various destinations.\n\nWhen you run a Dataflow job, the job transitions through various\nstates, such as `JOB_STATE_QUEUED`, `JOB_STATE_RUNNING`, and `JOB_STATE_DONE`.\nDataflow integration with Eventarc lets you trigger an\naction when a job changes state.\n\nBecause Eventarc is a managed service, you don't need to\nprovision or manage the underlying infrastructure.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Eventarc APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=eventarc.googleapis.com,eventarcpublishing.googleapis.com&redirect=https://console.cloud.google.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Eventarc APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=eventarc.googleapis.com,eventarcpublishing.googleapis.com&redirect=https://console.cloud.google.com)\n\n\u003cbr /\u003e\n\nTo use the Eventarc API, your project must have enough\n[quota](/eventarc/docs/quotas). Also, the service account associated with the\nEventarc trigger must have the [appropriate permissions](/eventarc/docs/all-roles-permissions).\n\nChoose an event destination\n---------------------------\n\nChoose an [event destination](/eventarc/docs/overview#targets) to receive the\nevent. The destination determines the next step in your workflow.\n\nFor example:\n\n- To send an SMS alert, you might use Cloud Run functions to create a standalone HTTP trigger.\n- For a more complex workflow, you might use Workflows.\n- If your Dataflow pipeline is part of a larger solution that runs on Google Kubernetes Engine, the trigger can route the event to a GKE service running in your cluster.\n\nFor more information about this style of architecture, see\n[Event-driven architectures](/eventarc/docs/event-driven-architectures) in the\nEventarc documentation.\n\nCreate a trigger\n----------------\n\nTo create an Eventarc trigger for Dataflow job\nstate changes, refer to one of the following documents:\n\n- [Route Dataflow events to Cloud Run](/eventarc/docs/run/route-trigger-dataflow)\n- [Route Dataflow events to Google Kubernetes Engine](/eventarc/docs/gke/route-trigger-dataflow)\n- [Route Dataflow events to Workflows](/eventarc/docs/workflows/route-trigger-dataflow)\n- [Create a trigger for Cloud Run functions](/eventarc/docs/functions/create-triggers)\n\nOptionally, you can filter events by Dataflow job ID. For\nexample, you can select job IDs that match a regular expression. For more\ninformation, see [Understand path patterns](/eventarc/docs/path-patterns).\n\nProcess events\n--------------\n\nThe event data describes the Dataflow job at the time the event\nwas triggered. The payload is similar to the\n[`Job`](/dataflow/docs/reference/rest/v1b3/projects.jobs#Job) resource type,\nwith the `steps`, `pipeline_description`, and `transform_name_mapping` fields\nomitted. Also, depending on the job state, some fields might not be present.\n\nThe following shows an example payload: \n\n {\n \"id\":\"2023-04-13_16_28_37-12345678\",\n \"projectId\":\"my-project\",\n \"name\":\"job1\",\n \"currentState\":\"JOB_STATE_QUEUED\",\n \"currentStateTime\":\"2023-04-13T23:28:37.437622Z\",\n \"createTime\":\"2023-04-13T23:28:37.437622Z\",\n \"location\":\"us-central1\",\n \"startTime\":\"2023-04-13T23:28:37.437622Z\"\n }\n\nFor more information about job states, see the following topics:\n\n- [`JobState`](/dataflow/docs/reference/rest/v1b3/projects.jobs#jobstate)\n- [Life of a Dataflow job](/dataflow/docs/guides/pipeline-workflows#life-of-a-job)\n\nWhat's next\n-----------\n\n- [Design Dataflow pipeline workflows](/dataflow/docs/guides/pipeline-workflows).\n- Read the [Eventarc documentation](/eventarc/docs/overview)."]]