Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Stackdriver logging advanced filter to view logs across multiple Compute Engine instances by instance name
textPayload:"execution time"

This comment has been minimized.

Copy link
Owner Author

@craigafinch craigafinch commented Mar 27, 2018

Use case: I'm a developer troubleshooting an error on a cluster of web servers, and I want to view the Apache logs from all servers, in chronological order.

The Stackdriver Logging docs only show you how to select instances by their instance ID. Finding each server's ID is a hassle, especially for a large cluster, and it is especially impractical for managed instance groups that auto-scale. This filter allows you to select log entries from an arbitrary group of servers with a partial name match. For example, assume that your servers are Google Compute Engine instances that are named [region]-[zone]-web-[id].

  • logName selects the log (use auto-complete to find the exact name)
  • labels selects the servers by a partial name match
  • textPayload searches within each log entry (in this case, for PHP processes that exceeded the max execution time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment