Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo documento descrive come creare flussi di lavoro basati su eventi attivati da modifiche dello stato nei job Dataflow.
Ad esempio, il workflow potrebbe:
Invia un avviso a un tecnico di turno se un job critico non va a buon fine.
Notifica agli utenti il completamento di un job batch o avvia un altro job Dataflow.
Esegui la pulizia delle risorse utilizzate da un job, ad esempio i bucket Cloud Storage.
Panoramica
Eventarc è un servizio Google Cloud che può ascoltare gli eventi provenienti da altri servizi e indirizzarli a varie destinazioni.
Quando esegui un job Dataflow, il job passa attraverso vari
stati, ad esempio JOB_STATE_QUEUED, JOB_STATE_RUNNING e JOB_STATE_DONE.
L'integrazione di Dataflow con Eventarc ti consente di attivare un'azione quando un job cambia stato.
Poiché Eventarc è un servizio gestito, non devi eseguire il provisioning o gestire l'infrastruttura sottostante.
Prima di iniziare
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.
Per utilizzare l'API Eventarc, il tuo progetto deve disporre di una quota sufficiente. Inoltre, il account di servizio associato al
trigger Eventarc deve disporre delle autorizzazioni appropriate.
Scegliere una destinazione per l'evento
Scegli una destinazione evento per ricevere l'evento. La destinazione determina il passaggio successivo del flusso di lavoro.
Ad esempio:
Per inviare un avviso SMS, puoi utilizzare le funzioni Cloud Run per creare un trigger HTTP autonomo.
Per un workflow più complesso, puoi utilizzare Workflows.
Se la pipeline Dataflow fa parte di una soluzione più ampia che
viene eseguita su Google Kubernetes Engine, il trigger può indirizzare l'evento a un servizio GKE
in esecuzione nel cluster.
Per saperne di più su questo stile di architettura, consulta
Architetture basate su eventi nella
documentazione di Eventarc.
Crea un trigger
Per creare un trigger Eventarc per le modifiche di stato del job Dataflow, consulta uno dei seguenti documenti:
(Facoltativo) Puoi filtrare gli eventi in base all'ID job Dataflow. Ad esempio, puoi selezionare gli ID job che corrispondono a un'espressione regolare. Per ulteriori informazioni, consulta Informazioni sui pattern di percorso.
Elaborare eventi
I dati dell'evento descrivono il job Dataflow al momento dell'attivazione dell'evento. Il payload è simile al tipo di risorsa
Job, con i campi
steps, pipeline_description e transform_name_mapping omessi. Inoltre, a seconda dello stato del job, alcuni campi potrebbero non essere presenti.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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)."]]