从 GKE 上运行的 Rails 应用收集错误需要执行哪些步骤?
我已将 stackdriver gem 添加到我的 Rails 应用程序中,并使用以下命令创建了一个自定义角色errorreporting.errorEvents.create
允许。
这个角色被赋予了Compute Engine 默认服务帐号
我解释the docs https://cloud.google.com/error-reporting/docs/setup/ruby在 GKE 上运行时不必执行以下设置:
# Add this to config/environments/*.rb
Rails.application.configure do |config|
# Stackdriver Error Reporting specific parameters
config.google_cloud.error_reporting.project_id = "YOUR-PROJECT-ID"
config.google_cloud.error_reporting.keyfile = "/path/to/service-account.json"
end
我手动创建了一个异常
这给了我有价值的信息:
irb(main):001:0> Google::Cloud::ErrorReporting.report Exception.new(msg: "from console")
=> nil
irb(main):002:0> {:msg=>"from console"} (Exception)
Google::Cloud::PermissionDeniedError: 7:Stackdriver Error Reporting API has not been used in project NNNNN before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/clouderrorreporting.googleapis.com/overview?project=NNNN then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
启用 API 后,我收到此错误:
irb(main):004:0> {:msg=>"from console"} (Exception)
Google::Cloud::PermissionDeniedError: 7:User not authorized.
那么,我必须向哪个用户授予哪个权限才能完成这项工作? :-|
这似乎是权限问题,所以安装和配置后谷歌云红宝石 https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-error_reporting.
然后,您需要启用 Stackdriver 错误报告 API。
然后,您需要将角色“roles/errorreporting.writer”添加到默认计算服务帐户。
gcloud 容器集群创建 example-cluster-name --scopeshttps://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloud-platform
创建集群时,您需要为平台添加 --scope 标志,请参阅上面的示例:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)