Search code examples
google-cloud-platformgcloudstackdriver

Find logs between timestamps using stackdriver CLI


I need to find logs between two timestamps using stackdriver CLI. I used the below command.

gcloud beta logging read "timestamp>=\"2017-02-19T00:00:00Z\" AND timestamp<\"2017-03-14T00:00:00Z\"" 

But its giving me the error:

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

Here is my gcloud version details

gcloud --version


Solution

  • I'm a product manager with Stackdriver logging. We've tested the command and it seemed to work fine. The issue may be with Windows command shell? One guess is that perhaps the ">" and "<" need "/" in front? Copying and pasting your query into cloud shell works fine.

    Kudos go to a Google engineer who recommended this: I came across this issue a lot with gcloud --filter commands on windows. The following works:

    gcloud beta logging read "timestamp^>=""2017-02-19T00:00:00Z"" AND ""timestamp^<2017-03-14T00:00:00Z"""
    

    Note use of double "" and ^ escape characters.

    You can add --verbosity debug to the command line, it will show you how exactly parameters were understood by gcloud.