Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Neste documento, descrevemos como criar fluxos de trabalho orientados por eventos acionados por alterações de estado nos jobs do Dataflow.
Por exemplo, seu fluxo de trabalho pode:
Enviar um alerta para um engenheiro de plantão se um job crítico falhar.
Notifique os usuários quando um job em lote for concluído ou inicie outro job do Dataflow.
Limpar recursos usados por um job, como buckets do Cloud Storage.
Visão geral
O Eventarc é um serviço do Google Cloud que pode detectar eventos de outros serviços e roteá-los para vários destinos.
Quando você executa um job do Dataflow, ele passa por vários estados, como JOB_STATE_QUEUED, JOB_STATE_RUNNING e JOB_STATE_DONE.
A integração do Dataflow com o Eventarc permite que você acione uma ação quando um job mudar de estado.
Como o Eventarc é um serviço gerenciado, você não precisa
provisionar ou gerenciar a infraestrutura subjacente.
Antes de começar
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.
Para usar a API Eventarc, seu projeto precisa ter cota suficiente. Além disso, a conta de serviço associada ao
acionador do Eventarc precisa ter as permissões apropriadas.
Escolha um destino para o evento
Escolha um destino de evento para receber o evento. O destino determina a próxima etapa no seu fluxo de trabalho.
Por exemplo:
Para enviar um alerta por SMS, você pode usar as funções do Cloud Run para criar um acionador HTTP autônomo.
Para um fluxo de trabalho mais complexo, use fluxos de trabalho.
Se o pipeline do Dataflow fizer parte de uma solução maior executada no Google Kubernetes Engine, o gatilho poderá rotear o evento para um serviço do GKE em execução no cluster.
Opcionalmente, é possível filtrar eventos por ID do job do Dataflow. Por exemplo, selecione códigos de job que correspondam a uma expressão regular. Para mais informações, consulte Entender os padrões de caminho.
Processar eventos
Os dados do evento descrevem o job do Dataflow no momento em que o evento foi acionado. O payload é semelhante ao tipo de recurso Job, com os campos steps, pipeline_description e transform_name_mapping omitidos. Além disso, dependendo do estado do job, alguns campos podem não estar presentes.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)."]]