Amrish Mishra
Amrish Mishra

Reputation: 180

GCP Cloud Shell Command Equivalent For Python SDK

I have command to retrieve stackdriver logs in specific file and it is as below,

gcloud logging read "resource.type=\"bigquery_resource\" AND timestamp >= \"2019-12-03T00:00:00Z\" AND timestamp <= \"2019-12-04T05:30:00Z\" AND protoPayload.serviceData.jobCompletedEvent.job.jobStatistics.totalBilledBytes > 0" --format json > logs_data.json

Willing to know if their is any other way to do the same, using python script or python SDK for GCP.

Upvotes: 1

Views: 228

Answers (1)

Pradeep Bhadani
Pradeep Bhadani

Reputation: 4721

You can find the sample python code example here. The REST API method used to retrieve log entries would be entries.list.

For more details on how to setup python to talk to GCP Stackdriver: https://cloud.google.com/logging/docs/quickstart-python

Hope this helps.

Upvotes: 4

Related Questions