-
Notifications
You must be signed in to change notification settings - Fork 593
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
Add Cloud Logging structured logs for Java and Python services #498
Comments
Tested with an older, pre-UWSGI (gunicorn instead) version of the Python services -- release v0.2.0 https://github.com/GoogleCloudPlatform/bank-of-anthos/releases/tag/v0.2.0 Reason for testing that older version is Gunicorn had a separate logging.conf for the 3 python services, which we lost when we moved to UWSGI https://github.com/GoogleCloudPlatform/bank-of-anthos/blob/3ea9ebc1382ebc98133e6b17e532a99369404807/src/frontend/logging.conf But the "info as error" bug seems to date back to when we had Gunicorn - seeing the same behavior on 0.2.0. |
After diving into the code + history + recommended ways of doing Python + Google Cloud Logging, I don't know if we ever set this up correctly, I think the log level has always rendered wrong in Cloud Logging. Looking at the Cloud Ops Sandbox's python services -- example -- they have set up structured JSON logging using python-json-logger, overriding the severity field to correctly populate it before sending it to Cloud Logging. I've replicated this in the Python services and now the level is showing up correctly. Note that only the "message" shows up in the cloud logging message field, not For consistency, I updated the Java service logs to use structured JSON as well, so that only the message shows up in the cloud logging message, not Python stdout - frontend-8577ff7fbf-czczh front {"asctime": "2021-06-04 21:56:19,445", "levelname": "INFO", "funcName": "payment", "message": "Payment initiated successfully.", "timestamp": 1622843779.445502, "severity": "INFO"} Java stdout:
And they can see those fields in the cloud logging UI -- The mislabeled in-cluster Postgres logs are still all labeled as err - need to do more research to figure out how to proceed there. |
I have tested this with the latest commit and do not see any false positive with Python services, likely due to #501. I do still see the PostgresDB instances mis-logging everything as error (due to Postgres' default log destination being set to Additionally, I'm seeing false negatives coming from the frontend (and potentially all Python services): I'm also not seeing any JSON payload for the false negatives on the Java side. Rather, the errors appear as plain text: |
Only seeing this mislabeled severity with
INFO
logs --> mistakenly logged asERROR
.Services where I see this: userservice, contacts, and frontend (all the python services), the two in-cluster databases (accounts and ledger). Java services are unaffected.
Example:
Strangely, the line of code there is
app.logger.info
but it's getting mislabeled in severity, somewhere.The text was updated successfully, but these errors were encountered: