{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5322","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5322/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5322/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5322/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5322","id":322549358,"number":5322,"title":"Stackdriver Logging payload_pb unreadable","user":{"login":"VenturaAtDD","id":31896028,"avatar_url":"https://avatars2.githubusercontent.com/u/31896028?v=4","gravatar_id":"","url":"https://api.github.com/users/VenturaAtDD","html_url":"https://github.com/VenturaAtDD","followers_url":"https://api.github.com/users/VenturaAtDD/followers","following_url":"https://api.github.com/users/VenturaAtDD/following{/other_user}","gists_url":"https://api.github.com/users/VenturaAtDD/gists{/gist_id}","starred_url":"https://api.github.com/users/VenturaAtDD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VenturaAtDD/subscriptions","organizations_url":"https://api.github.com/users/VenturaAtDD/orgs","repos_url":"https://api.github.com/users/VenturaAtDD/repos","events_url":"https://api.github.com/users/VenturaAtDD/events{/privacy}","received_events_url":"https://api.github.com/users/VenturaAtDD/received_events","type":"User","site_admin":false},"labels":[{"id":311535631,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/labels/api:%20logging","name":"api: logging","color":"f8f8f8","default":false},{"id":77438584,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/labels/type:%20question","name":"type: question","color":"c5def5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-12T23:06:21Z","updated_at":"2018-05-16T17:42:06Z","closed_at":"2018-05-16T17:38:31Z","author_association":"NONE","body":"I am using Python3 (google-cloud-logging (1.4.0)) to query Stackdriver for GCP logs. Unfortunately, the log entries that have important data are returned to me as \"NoneType\" instead of as a \"dict\" or a \"str\". The resulting \"entry.payload\" is type \"None\" and the \"entry.payload_pb\" has the data I want, but it is garbled (most other log entries are readable and present in \"entry.payload\").\r\n\r\nWhen I use gcloud (0.18.3) to query for these records based on their insertIDs, I get a clean copy in entry.payload, so I know GCP writes the data in a sane way (I can access it through the Stackdriver portion of the GCP console as well).\r\n\r\nMy code looks something like this:\r\n\r\nfrom google.cloud.logging import Client, ASCENDING, DESCENDING\r\nfrom google.oauth2.service_account import Credentials\r\n\r\nprojectName = 'my_project'\r\nmyFilter = 'logName=\"projects/' + projectName + '/logs/compute.googleapis.com%2Factivity_log\"'\r\n\r\nclient = Client(project = projectName)\r\nentries = client.list_entries(order_by=DESCENDING, page_size = 500, filter_ = myFilter)\r\nfor entry in entries:\r\n    if isinstance(entry.payload, dict):\r\n        print(entry.payload)\r\n    if isinstance(entry.payload, str):\r\n        print(entry.payload)\r\n    if isinstance(entry.payload, None):\r\n        print(entry.payload_pb)\r\n\r\nThe garbled entry.payload_pb entries all start the same and look something like this:\r\n\r\n`type_url: \"type.googleapis.com/google.cloud.audit.AuditLog\"\r\n value: \"\\032;\\n9gcp-user@my-project.iam.gserviceaccount.com\"I\\n\\r129.105.16.28\\0228`"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/comments/389605218","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5322#issuecomment-389605218","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5322","id":389605218,"user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars2.githubusercontent.com/u/242750?v=4","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"created_at":"2018-05-16T17:42:06Z","updated_at":"2018-05-16T17:42:06Z","author_association":"MEMBER","body":"For reference, here are the [docs for the `AuditLog` message](https://cloud.google.com/logging/docs/reference/audit/auditlog/rest/Shared.Types/AuditLog)."}}
{"actor":{"display_login":"tseaver"}}