I've been using the grep-for-textPayload approach for a while which works for most things, but if you ever wind up needing to incorporate multiple keys from each log message I stumbled on a decent approach via jq, which gives you access to all of the keys and a format string syntax.
For example to add back a timestamp to each log line: gcloud beta logging read '<filter-query>' --format=json | jq -rnc --stream 'fromstream(1|truncate_stream(inputs)) | @text "\(.timestamp) \(.textPayload)"' Or just extracting the textPayload in what feels like a more predictable manner than grep/cut if the formatting ever changes: gcloud beta logging read '<filter-query>' --format=json | jq -rnc --stream 'fromstream(1|truncate_stream(inputs)) | .textPayload' Very much agreed re 'nothing beats having a CLI that easily facilitates ad-hoc exploration using "grep, perl, custom scripts etc"'. My apologies for digging up an old discussion, but I hope this is helpful to anyone who finds this thread in the future! Wednesday, June 22, 2016 at 5:15:47 AM UTC-4, Jonas Tingeborn wrote: > > *Is there a way to get the gcloud command to output just the textPayload > attribute values?* > > I haven't managed to figure out a good way of how to extract only the *log > lines* that an app submitts to stackdriver, without all the metadata > associated with the log entry, of which the actual log line is just one of > many attributes. > > Currently I've had to resort to some shell-fu in order to get the log > output in a form akin to what logging locally to file would have yielded. > To get logs from a given docker container in container engine I presently > do something like the following: > > gcloud beta logging read '*<query-expression>*' --format list | grep ' > textPayload: ' | cut -c17- > relevant_log_lines > > *PS. thanks for providing a CLI for stackdriver, very handy indeed.* > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/4df90aa1-085b-4352-9d9f-a9124646fc5c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
