GoogleCloudPlatform / stackdriver-metrics-export

Apache License 2.0
38 stars 27 forks source link

testing doesn't work #8

Open yamamoto52 opened 4 years ago

yamamoto52 commented 4 years ago

in few last lines I have problem :

export TIMESTAMP=$(date -d "-2 hour"  +%Y-%m-%dT%k:%M:00Z)
export BATCH_ID=$(gcloud logging read "resource.type=\"gae_app\" AND resource.labels.module_id=\"list-metrics\" AND logName=\"projects/$PROJECT_ID/logs/appengine.googleapis.com%2Frequest_log\" AND protoPayload.line.logMessage:\"batch_id:\" AND timestamp >= \"$TIMESTAMP\"" --limit 1 --format json | grep "batch_id:" | awk '{ print substr($3,1,32); }')

output from second line is :

ERROR: (gcloud.logging.read) INVALID_ARGUMENT: The value '2020-01-27t 8:05:00z' is of incorrect type.
tzehon commented 3 years ago

I had this error too. I experimented a bit and it seems like the error arises because the query syntax doesn't recognize the white space between the date and the time.

Instead of "%k", can you try "%H"? the command would then look like :export TIMESTAMP=$(date -d "-2 hour" +%Y-%m-%dT%H:%M:00Z). I tried this in Cloud Shell and the Log Explorer and it did return me results in the next step when saving to the BATCH_ID.