Search code examples
google-cloud-platformgoogle-cloud-shell

SDK Gcloud logging timestamp filter


I am having problem while trying to filter my log files to a specific period of time. Everything beside timestamps works fine when i'm trying to write a command. The moment everything looks good:

gcloud logging read "resource.type=XXX logName=projects/YYY/logs/appengine.googleapis.com%2Fnginx.health_check" > test.txt

All other things like --limit or --freshness are working without problems, but when i'm trying to get a period of time in my text file the command stops working. I'm getting information:

The file name, directory name, or volume label syntax is incorrect.

I've tried many things and this is command which gives me some error at least:

gcloud logging read "resource.type=XXX logName=projects/YYY/logs/appengine.googleapis.com%2Fnginx.health_check timestamp='2020-01-22T14:02:41.41Z'"

Please help me with correct syntax of specifying timestamps to get any period of time as a result.


Solution

  • I got it!

    gcloud logging read "resource.type=XXX logName=projects/YYY/logs/appengine.googleapis.com%2Fnginx.health_check timestamp^>=""2020-01-21T11:00:00Z"" timestamp^<=""2020-01-22T11:00:00Z""" >t.txt
    

    I found it here: Find logs between timestamps using stackdriver CLI

    Thank you Braulio Baron for your help!