How to filter log entries by timestamp in gcloud logging command line

google-cloud-platform

Any one knows how to filter log entries by timestamp in gcloud logging command line? From google cloud site – https://cloud.google.com/logging/docs/reference/tools/gcloud-logging, I learned to read logs by command

gcloud logging read "resource.type=gce_instance AND logName=projects/[PROJECT_ID]/logs/syslog AND textPayload:SyncAddress" --limit 10 --format json

I want to know how to filter by timestamp. I need to read logs in a particular period.

thanks

Best Answer

I found the answer in https://cloud.google.com/logging/docs/view/query-library?_ga=2.48552804.-39743739.1582783979

the filter could be like this timestamp>="2020-07-01T00:00:00Z" AND timestamp<="2020-07-01T00:02:00Z"

Related Topic