For health points you do not need to rely on grep
. Filters are included in the SDK , so you can simply filter the output. However, you just hide them on the terminal, but the SDK will still get them from the API (as with use grep
). A more optimal way would be to use gcloud logging read 'resource.type="gae_app" AND logName:"logs/appengine.googleapis.com%2Frequest_log" AND protoPayload.resource!="/health"' --order desc
, since you only request logs matching the custom filter. This gives a fairly detailed log, so you can format the output directly to the SDK to make it look like you like gcloud app logs tail
.
Since it gcloud logging
does not have a tail mode, you can simply wrap it in watch
like:
watch 'gcloud logging read "resource.type=\"gae_app\" AND logName:\"logs/appengine.googleapis.com%2Frequest_log\" AND protoPayload.resource!=\"/health\"" --order desc --limit 1'
--format
, , --limit
- , ( , ).
, gcloud app logs tail -s default --log-http
, SDK, , API, , .
, API, watch
.
API , .
, , ( ). - , .
. GAE, , protoPayload ( , ).
, API (: quote escape-hell):
watch -tcn 0.5 'curl -H"Authorization: Bearer $(gcloud auth print-access-token)" \
-H"Content-Type: application/json" \
"https://logging.googleapis.com/v2/entries:list?fields=entries%2FprotoPayload" \
-d"{
\"filter\":\"resource.type=\\\"gae_app\\\"
logName=\\\"projects/$(gcloud config get-value project)/logs/appengine.googleapis.com%2Frequest_log\\\"\",
\"pageSize\":$(tput lines),
\"orderBy\":\"timestamp desc\",
\"resourceNames\": [
\"projects/$(gcloud config get-value project)\"
]
}" 2>\dev\null |jq -cC ".entries[].protoPayload | { timestamp: .startTime, method, status, latency, URL: (.host + .resource) }"'
jq
, , .