Usa Eventarc para administrar trabajos de Dataflow
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En este documento, se describe cómo crear flujos de trabajo basados en eventos y activados por
cambios de estado en tus trabajos de Dataflow.
Por ejemplo, tu flujo de trabajo podría hacer lo siguiente:
Enviar una alerta a un ingeniero de guardia si falla un trabajo esencial
Notificar a los usuarios cuando se complete un trabajo por lotes o se inicie otro
trabajo de Dataflow
Liberar los recursos que usa un trabajo, como los buckets de Cloud Storage
Descripción general
Eventarc es un servicio de Google Cloud que puede
escuchar eventos de otros servicios y enrutarlos a varios destinos.
Cuando ejecutas un trabajo de Dataflow, este pasa por varios
estados, como JOB_STATE_QUEUED, JOB_STATE_RUNNING y JOB_STATE_DONE.
La integración de Dataflow con Eventarc te permite activar una
acción cuando un trabajo cambia de estado.
Debido a que Eventarc es un servicio administrado, no necesitas
aprovisionar ni administrar la infraestructura subyacente.
Antes de comenzar
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 la API de Eventarc, el proyecto debe tener suficiente
cuota. Además, la cuenta de servicio asociada con el
activador de Eventarc debe tener los permisos adecuados.
Elige el destino de un evento
Elige un destino de evento
para recibirlo. El destino determina el siguiente paso en tu flujo de trabajo.
Por ejemplo:
Para enviar una alerta por SMS, puedes usar las funciones de Cloud Run para crear un activador
HTTP independiente.
Para un flujo de trabajo más complejo, puedes usar Workflows.
Si tu canalización de Dataflow es parte de una solución más grande que se ejecuta en Google Kubernetes Engine, el activador puede enrutar el evento a un servicio de GKE que se ejecuta en tu clúster.
De manera opcional, puedes filtrar eventos por ID de trabajo de Dataflow. Por ejemplo, puedes seleccionar los IDs de trabajo que coincidan con una expresión regular. Para obtener más información, consulta Información sobre los patrones de ruta de acceso.
Procesa eventos
Los datos del evento describen el trabajo de Dataflow en el momento en que se activó el
evento. La carga útil es similar al
tipo de recurso Job,
con los campos steps, pipeline_description y transform_name_mapping
omitidos. Además, según el estado del trabajo, es posible que algunos campos no estén presentes.
A continuación, se muestra una carga útil de ejemplo:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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)."]]