Create a gist now

Instantly share code, notes, and snippets.

Embed
Google Stackdriver logging advanced filter to view logs across multiple Compute Engine instances by instance name
resource.type="gce_instance"
logName="projects/my-project-name/logs/apache-error"
labels."compute.googleapis.com/resource_name":"-web-"
textPayload:"execution time"
@craigafinch

This comment has been minimized.

Show comment
Hide comment
@craigafinch

craigafinch 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)
Owner

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