-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: structured log handler drops reserved fields in json_fields #634
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments
…eapis/python-logging into fix-structured-log-reserved-fields
@daniel-sanche I may have run into an issue with one of the recent logging changes in here |
Hey @nickkieffer, looking at the linked thread, it looks like you may not be using the The code you linked looks like it's just using the standard Python logging module, printing to standard out:
If you want to use this GCP logging library, you need to run this code as well:
If you're using GKE though, you shouldn't actually need to use this library directly, since GKE should have logging agents running on the nodes to extract your stdout/stderr logs into Cloud Logging automatically. You may want to look into the GKE docs to see why your logs aren't showing up (maybe your cluster was set up with the logging agents disabled?) This guide might be a good place to start reading. One last thing to check: looking at this comment, it seems like you're looking for the logs using the GKE Log view. That page shows a filtered view of the logs coming in to your project, trying to find only the logs related to that GKE pod. You may also want to look at the full stream of logs in the main GCP Cloud Logging interface (https://console.cloud.google.com/logs). It's possible your logs are being ingested into Cloud Logging, but with missing metadata, and so they aren't showing up in the filtered GKE Log view |
Yeah I checked the un-filtered views too and the logs aren't available 🤷 |
Disregard me, looks like the ops team found an issue in our configuration. Sorry for the distraction! |
Fixes: #543
Adding reserved fields like
severity
to thejson_fields
for the StructuredLogHandler was causing issues, as the json fields would attempt to overwrite the fields in the LogEntry, rather than staying in the jsonPayload, as intended.This PR fixes this by maintaining a list of reserved field names (taken from the structured logging spec), and filtering them out of
json_fields
before printing the log