tribo32
tribo32

Reputation: 335

How to specify run id in a DAG run in Apache Airflow

When triggering a DAG from the webserver and go to the graph view the run id is something like below:

enter image description here

I can specify this name when running through the command line using 'airflow trigger_dag' and specifying the 'run_id' but I don't know how to specify this ID when triggering the DAG through the webserver?

Has anyone found a way to do this?

Upvotes: 2

Views: 7389

Answers (1)

Vinit Bodhwani
Vinit Bodhwani

Reputation: 435

Airflow 2.0 released stable REST APIs where we can mention specific dag_run_id. Here is the link: https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/post_dag_run

dag_run_id: The value of this field can be set only when creating the object. If you try to modify the field of an existing object, the request fails with an BAD_REQUEST error.

If not provided, a value will be generated based on execution_date.

If the specified dag_run_id is in use, the creation request fails with an ALREADY_EXISTS error.

This together with DAG_ID are a unique key.

execution_date: The execution date. This is the time when the DAG run should be started according to the DAG definition. The value of this field can be set only when creating the object. If you try to modify the field of an existing object, the request fails with an BAD_REQUEST error. This together with DAG_ID are a unique key.

state: It is recommended not to provide this parameter while triggering REST APIs.

conf: JSON object describing additional configuration parameters. The value of this field can be set only when creating the object. If you try to modify the field of an existing object, the request fails with an BAD_REQUEST error.

Upvotes: 2

Related Questions