0

I deployed a toy program to a VM instance running on Google Compute Engine (GCE). This toy program happens to log formatted error messages to the standard error stream (stderr). The VM instance has Stackdriver logging enabled and I am able to see some of my program's error messages interspersed with many other messages which are presumably generated by GCE itself.

Is it possible to filter the Stackdriver log viewer to display only the messages sent from my VMs standard error stream to simplify troubleshooting?

Ideally I would prefer not to rely on any client libraries, for simplicity. I've considered creating a filter to match on a special unique token that I could inject from an environment variable but that seems complicated for what seems like an easy task (viewing standard log messages).

The log messages look like this:

2018-10-20T16:03:31.262075836Z | listening for https at "localhost:443"
2018-10-20T16:03:31.257283434Z | foo
2018-10-20T16:03:32.012318385Z | bar
2018-10-20T16:03:38.119439321Z | ERROR: something bad happened
2018-10-20T16:03:38.127334354Z | FATAL: program terminated
Maxim
  • 4,075
  • 1
  • 14
  • 23
maerics
  • 151,642
  • 46
  • 269
  • 291

1 Answers1

1

I recommend you to write an Advanced Logs Filter. Actually, advanced log filters can be used in the Logs Viewer, the Stackdriver Logging API, or the command-line interface. And you can use a special syntax to specify the exact logs you want to see.

Also, you can watch a video of advanced filters which provided by Google Cloud Platform team.

Milad Tabrizi
  • 480
  • 3
  • 15
  • Any advice on what filter text will produce _only_ log lines generated by my program/VM and _not_ the GCP platform messages? – maerics Oct 22 '18 at 16:39
  • Go to the [Stackdriver logging page](https://console.cloud.google.com/logs/) > Select the proper resource > Select one of the log lines > Choose "Expand all" > Select the proper log you are looking for > Select "Show matching entries" – Milad Tabrizi Oct 24 '18 at 20:59