最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

authentication - How to log the authenticated user or service account in Cloud Run request logs? - Stack Overflow

programmeradmin3浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论