I am running a containerized application with the standard Python logger
on aCOS on GCE. I followed the official documentation and connected my logger to Cloud Logging via --metadata google-logging-enabled=true
option used during the creation of VM with the container.
However, all of my logs appear as Default
severity, regardless of their actual type, which is being logged in jsonPayload.message
, under level.
Example:
{
"insertId": "d941eraehq2oe74vz",
"jsonPayload": {
"cos.googleapis.com/container_name": "klt-ingest-tfpo",
"message": "{\"message\":\"Faulty nested document: unclosed token: line 1, column 0\",\"level\":\"ERROR\",\"name\":\"Parser\",\"pathname\":\"\\/app\\/src\\/parsers\\/parser.py\",\"lineno\":252,\"time\":\"2023-03-01T19:59:44.714053\"}\n",
"cos.googleapis.com/container_id": "50a03fa8815bbc6b15dfe2bfac78c826721460b878ded8788f93c157ff0d872f",
"cos.googleapis.com/stream": "stderr"
},
"resource": {
"type": "gce_instance",
"labels": {
"zone": "ZONE",
"project_id": "PROJECT_NAME",
"instance_id": "INSTANCE_ID"
}
},
"timestamp": "2023-03-01T19:59:45.538228300Z",
"labels": {
"compute.googleapis.com/resource_name": "45a5a431640f"
},
"logName": "PROJECT_NAME/logs/cos_containers",
"receiveTimestamp": "2023-03-01T19:59:50.755964042Z"
}
Is there a way for Cloud Logger to pick up the log severity type from the logs, other than using google's logging client inside the module?
I presume I could also filter by contents of jsonPayload - is there a way to access the level
field inside it?