Find logs between timestamps using stackdriver CLI

被刻印的时光 ゝ 提交于 2020-02-24 05:13:21

问题


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


回答1:


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.




回答2:


The above answer doesn't seem to work anymore. Here's the new command.

gcloud logging read 'receiveTimestamp>="2019-08-08T21:00:00Z" AND receiveTimestamp<="2019-08-08T22:00:00Z"'

Actually, this is simpler. The escape characters has been removed along with the double "double quotes". :)



来源:https://stackoverflow.com/questions/42817841/find-logs-between-timestamps-using-stackdriver-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!