GoogleCloudPlatform / k8s-stackdriver

Apache License 2.0
390 stars 211 forks source link

Linking traces to log entries #164

Open mwuertinger opened 6 years ago

mwuertinger commented 6 years ago

I'm running a Golang HTTP server on K8s using OpenCensus for tracing. In my logs I set the JSON field trace to "projects/$PROJECT/traces/$TRACE_ID".

If I click on the "Log" link in a Stackdriver trace (see screenshot) I end up with zero log results. However, if I manually replace trace=... with jsonPayload.trace=... the filter works and I get the log entries associated with the trace I clicked on.

Is there anything I can do to make this work automatically? Ie. is there any way to set the trace field directly instead of just the jsonPayload.trace?

trace

rroller commented 4 years ago

Instead of trace as the JSON key, you need to use the key logging.googleapis.com/trace

Docs here https://cloud.google.com/logging/docs/agent/configuration#special_fields_in_structured_payloads