mackowi
mackowi

Reputation: 41

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.

Upvotes: 1

Views: 1167

Answers (2)

mackowi
mackowi

Reputation: 41

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!

Upvotes: 3

Joss Baron
Joss Baron

Reputation: 1524

The syntax error is in the timestamp, it should be with \ before the date's quotes:

gcloud logging read "resource.type=gae_app AND logName=projects/xxxx/logs/syslog AND timestamp=\"2020-01-22T14:02:41.41Z\""

For more detail have a look into gcloud logging read

Upvotes: 0

Related Questions