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

I have a FastAPI application deployed on Cloud Run, and I'm trying to capture the user or service

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744649667a4585825.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>