Stackdriver无法根据自定义指标创建警报

时间:2019-07-19 12:47:12

标签: google-cloud-platform stackdriver google-cloud-stackdriver

我有以下高级日志查询:

resource.type="container"
resource.labels.cluster_name="my-cluster"
resource.labels.namespace_id="mynamespace"
"SOMESTRING"

执行时将获取预期结果。

我根据此查询创建自定义指标。

然后,我选择“根据指标创建警报”(my-custom-metric)并尝试设置警报。

尝试保存警报策略完成后,出现以下错误:

  

错误400:字段alert_policy.conditions [0] .condition_threshold.filter的无效值为“ metric.type =“ logging.googleapis.com/user/my-custom-metric” resource.type =“ container”” :过滤器包含未知资源类型:容器

这怎么可能?

当我选择

时,Stackdriver会自动自动填充资源类型
  

根据指标创建警报

enter image description here

1 个答案:

答案 0 :(得分:2)

此错误消息的原因是在Kubernetes [1]中使用了传统堆栈驱动程序。

在传统Kubernetes Stackdriver中,GCP有2种不同的Kubernetes资源类型;

1- gke_container;仅用于指标

2-容器;仅用于日志

在新版本的Stackdriver中,GCP仅包含1个名为“ k8s_container”的资源类型,其中包括指标和日志。这意味着使用此新版本将彻底解决该问题。

默认情况下,在Kubernetes 1.14+上启用了新的Stackdriver版本,但是如果使用其他版本,则可以按照本文档[2] [3]中的说明手动进行更改。

但是,作为解决方法,您可以简单地将红色污染的资源类型删除到Stackdriver工作区中,然后添加“ gke_container”。那对我有用。

[1] https://cloud.google.com/monitoring/kubernetes-engine/migration#what-is-changing

[2] https://cloud.google.com/monitoring/kubernetes-engine/installing#migrating

[3] https://cloud.google.com/monitoring/kubernetes-engine/migration#upgrade-timeline

相关问题