如何从 GKE(google kubernetes 引擎)上的 Java 应用程序 运行 获取 GCP 错误报告
How get GCP Error Reporting from Java App running on GKE ( google kubernetes engine )
在 Java App Engine 的情况下,如果 Java 应用程序发生异常,我可以像 this
一样自动获取 GCP 错误报告
但是对于 Java GKE 上的应用程序,我无法获得 GCP 错误报告
怎么可以?
如doc Stackdriver Error Reporting is automatically enabled for App Engine environment applications. However on GKE, you must add the cloud-platform access scope when creating the cluster. The preferred way to collect the error is to able to post to Stackdriver Error Reporting using the REST API or Error Reporting Client Libraries中所述
你应该安装 Stackdriver Kubernetes Monitoring to GKE; while one can also use it together with Prometheus. theses features are currently still in beta stage (not being covered by any SLA). also see the Fluentd data collector, which is rather relevant to the Logging API
. this visual diagram 可能会解释最可靠的报告对象:
这个 shows how log from within a Java environment, there there's relevant documentation for Logging Application Events with Java(您可能真正要找的)。原则上,Java 环境中的记录器需要告诉本地代理发生了什么。
关于 Kubernetes 中的 Logging API
,参见 Logging Using Stackdriver and Customizing Stackdriver Logs for Kubernetes Engine with Fluentd;有不止一种方法可以做到这一点。
Monitoring API
和 Logging API
可以独立使用,但它们仍然观察到相同的资源和相同的时间线,这就是利用两者的原因。
关于所需的访问范围:
You must be an Owner of the project containing your cluster.
在 Java App Engine 的情况下,如果 Java 应用程序发生异常,我可以像 this
一样自动获取 GCP 错误报告但是对于 Java GKE 上的应用程序,我无法获得 GCP 错误报告
怎么可以?
如doc Stackdriver Error Reporting is automatically enabled for App Engine environment applications. However on GKE, you must add the cloud-platform access scope when creating the cluster. The preferred way to collect the error is to able to post to Stackdriver Error Reporting using the REST API or Error Reporting Client Libraries中所述
你应该安装 Stackdriver Kubernetes Monitoring to GKE; while one can also use it together with Prometheus. theses features are currently still in beta stage (not being covered by any SLA). also see the Fluentd data collector, which is rather relevant to the Logging API
. this visual diagram 可能会解释最可靠的报告对象:
这个
关于 Kubernetes 中的 Logging API
,参见 Logging Using Stackdriver and Customizing Stackdriver Logs for Kubernetes Engine with Fluentd;有不止一种方法可以做到这一点。
Monitoring API
和 Logging API
可以独立使用,但它们仍然观察到相同的资源和相同的时间线,这就是利用两者的原因。
关于所需的访问范围:
You must be an Owner of the project containing your cluster.