GKE中Rails应用无法向Google Cloud Error Reporting上报异常
Rails应用在GKE上配置Google Cloud Error Reporting无数据显示的排查与解决
问题场景
在GKE集群运行的Rails应用中配置Google Cloud Error Reporting时遇到异常:
- 已安装
stackdrivergem并在应用启动阶段引入 - 在Rails控制台手动调用上报接口返回结果正常:
irb(main):021:0> Google::Cloud::ErrorReporting.report(Exception.new(msg: "from console")).result => [true, [], nil]
- 确认
project_id配置正确,且在GCP控制台查看的是对应项目,但Error Reporting界面始终无法看到上报的错误记录
排查步骤
开启DEBUG日志级别查看RPC调用细节后,捕获到权限相关报错:
Failing with status #<struct Struct::Status code=7, details="User not authorized.", metadata={}, debug_error_string="UNKNOWN:Error received from peer ipv4:xxx.xxx.xxx.xx:443 {grpc_message:\"User not authorized.\", grpc_status:7, created_time:\"2024-05-23T17:54:30.826579798+00:00\"}">
解决方案
为GKE应用所使用的服务账号添加errorreporting.errorEvents.create权限角色,操作完成后,错误成功上报并在Google Cloud Error Reporting界面正常显示。
内容的提问来源于stack exchange,提问作者brentmc79
相关产品推荐
相关产品推荐

