I have a FastAPI application deployed on Cloud Run, and I'm trying to capture the user or service account that made a request in the Cloud Run logs. Currently, the logs only show standard Python request logs without any details about the authenticated user.
The application is secured using Cloud Run authentication, so requests are made by either authenticated users or service accounts. I would like to see this information in the logs without manually adding logging logic inside the FastAPI app (at least for now).
Checked Cloud Logging (Logs Explorer)
Looked at resource.type="cloud_run_revision" logs, but no user identity is shown. Also checked jsonPayload, but it doesn't contain details about who made the request. Increased logging verbosity in Cloud Run
Looked at run.googleapis/request_count metric, but it doesn’t include authentication details.
I was hoping that Cloud Run logs would automatically capture the authenticated user or service account making the request.
Ideally, I would like to avoid adding manual logging in the FastAPI application (I know that I could log the Authorization header, decode the JWT token, and extract user info, but I’d prefer to see if Cloud Run itself can provide this information).
Is there a way to configure Cloud Run, Cloud Logging, or Cloud Monitoring to capture and display this information?