Aron Einhorn
Aron Einhorn

Reputation: 389

Show httpRequest.latency in gcloud logs tail

I'm using gcloud app logs tail to show recent logs from App Engine. However, I only get to see the request url and the response code. How can I get more tags or labels, like 'response size', and 'latency'?

This is what I can see online in Logs Viewer.

Online Log Viewer Screenshot

And this is what I get from the commend.

Command Line Screenshot

Upvotes: 0

Views: 1921

Answers (2)

mochsner
mochsner

Reputation: 325

Not an answer, so this will probably be down voted, but to look at Response Sizes in Log Analytics, I've created below query...

SELECT
  http_request.request_method as method,
  http_request.request_url as url,
  AVG(http_request.response_size) as size,
FROM `<APP_NAME>.global._Default._Default`
where log_name = "projects/<APP_NAME>/logs/appengine.googleapis.com%2Fnginx.request" AND http_request.response_size IS NOT NULL
GROUP BY url, method
ORDER BY size DESC

Figure I'd share with the class...

Upvotes: 1

Joshua Koh
Joshua Koh

Reputation: 100

It looks like you are trying to get the full request log data for App Engine Flex. This can be accomplished using the gcloud logging read command, which uses basic and advanced filters to return data from Cloud Logging.

To pull the full request logs, you might start with a command like this, and tune it to your purposes.

watch -n 1 "gcloud logging read 'resource.type=\"gae_app\" AND logName=\"projects/YOUR_PROJECT_ID/logs/appengine.googleapis.com%2Fnginx.request\"' --limit=10 --format=json --freshness=1s"

Note a few things about this example:

  • Use watch -n 1 to run the command every second, which is a workaround for the lack of tail. This is coupled with the --freshness=1s flag to get only fresh data each time.

  • Be sure to change "YOUR_PROJECT_ID" to your project ID.

  • Based on your screenshot, it appears you're trying to read the nginx.request logs from a Flex app; this example reflects that. If you want to read a different log type, you'll need to tune the log query in the command accordingly.

The documentation for configuring flags for gcloud logging read is here.

The documentation for composing basic and advanced filters is here.

Upvotes: 1

Related Questions