https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
このフォーマットに当てはまるとStackdriverのコンソール上でタグ付け表示などがされ、フィルタリングしやすくなります
やり方
log_format acc_json_format escape=json '{"severity": "INFO",'
'"timestamp": "$time_iso8601",'
'"httpRequest": {'
'"requestMethod": "$request_method",'
'"requestUrl": "$request",'
'"requestSize": "$request_length",'
'"status": $status,'
'"responseSize": "$body_bytes_sent",'
'"userAgent": "$http_user_agent",'
'"remoteIp": "$remote_addr",'
'"serverIp": "$server_addr",'
'"referer": "$http_referer",'
'"latency": "$upstream_response_time",'
'"cacheLookup": false,'
'"cacheHit": false,'
'"cacheValidatedWithOriginServer": false,'
'"cacheFillBytes": "",'
'"protocol": "$server_protocol"'
'},'
# その他の情報
'"uuid": "$x_request_id",'
'"host": "$http_host",'
'"user_id": "$http_x_user_id",'
'"session_id": "$http_x_session_id"}';
access_log logs/access.log acc_json_format;
httpRequestに当てはまらないフィールドもjsonPayloadとして記録されるので便利です