在GKE上运行的Ruby的Stackdriver错误报告 [英] Stackdriver Error reporting for Ruby, running on GKE

本文介绍了在GKE上运行的Ruby的Stackdriver错误报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从运行在GKE上的Rails应用程序中收集错误需要采取哪些步骤?

我已将stackdriver gem添加到我的Rails应用程序中,并创建了具有errorreporting.errorEvents.create权限的自定义角色. 该角色已授予 Compute Engine默认服务帐户

I have added the stackdriver gem to my Rails app and I have created a custom role with the errorreporting.errorEvents.create permission. That role is given to the Compute Engine default service account

我将文档解释为一个人不必做在GKE上运行时,请执行以下设置:

I interpret the docs that one does not have to do the following setup when running on 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后,出现此错误:

After enabling the API, then I get this error:

irb(main):004:0> {:msg=>"from console"} (Exception)
Google::Cloud::PermissionDeniedError: 7:User not authorized.

那么,我必须授予哪个用户权限才能进行此工作? :-|

So, which permission do I have to give to which user to make this work? :-|

推荐答案

这似乎是权限问题,因此在安装和配置

This seems permission issue, so after installing and configuring google-cloud-ruby.

然后,您需要启用Stackdriver Error Reporting API.

Then, you need to Enable the Stackdriver Error Reporting API.

然后,您需要将角色"roles/errorreporting.writer"添加到默认的计算服务帐户.

Then you need to add the role "roles/errorreporting.writer" to the default compute service account.

gcloud容器群集创建示例群集名称--scopes https://www.googleapis .com/auth/cloud-platform

gcloud container clusters create example-cluster-name --scopes https://www.googleapis.com/auth/cloud-platform

创建集群时,需要为平台添加--scope标志,请参见上面的示例:

When you create the cluster you need to add --scope flag for platform see above an example:

这篇关于在GKE上运行的Ruby的Stackdriver错误报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆