sg_rs
sg_rs

Reputation: 491

How to list gcloud dataflow jobs filters to list only draining jobs?

I want to get the list of the jobs that have the status "Draining"

# gives 0 results 
gcloud dataflow jobs list --filter="status=Draining"
gcloud dataflow jobs list --filter="status=draining"
gcloud dataflow jobs list --filter="Status=Draining"
gcloud dataflow jobs list --filter="Status=draining"

# gives an error, because status can only be "all", "active", "terminated"
gcloud dataflow jobs list --status="Draining" 

Upvotes: 1

Views: 639

Answers (2)

kiran mathew
kiran mathew

Reputation: 2343

The flag STATUS has only three options active, all and terminated, that is why you are getting an error in your last command. You can follow this google cloud documentation to know more about the Status field.

To get the list of the jobs that have the are in "Draining" mode you can use bellow command:

gcloud dataflow jobs list --filter='STATE=DRAINING'

enter image description here

Addition to @Mazlum Tosun’s answer you only need to use --region if you want to have a region specific resource list.

Upvotes: 3

Mazlum Tosun
Mazlum Tosun

Reputation: 6572

I confirm the @kiran-mathew comment, you can use the following gcloud command to list all the Dataflow jobs with the draining state :

gcloud dataflow jobs list --region="europe-west1"  --filter='STATE=DRAINING'

An example of result :

JOB_ID NAME TYPE CREATION_TIME STATE REGION
2022-12-14_15_00_47-1012997933146788402 job-name Streaming 2022-12-14 23:00:48 Draining europe-west1

Upvotes: 3

Related Questions