我正在尝试为Google Cloud Platform中的Kubernetes Clusters创建警报策略。下面是示例代码。
service, err := monitoring.NewService(context.Background())
if err != nil {
log.Panicln(err)
return
}
mqlCondition := &monitoring.MonitoringQueryLanguageCondition{
Duration: "60s",
Query: `fetch k8s_pod
| metric 'kubernetes.io/pod/volume/utilization'
| filter
(resource.cluster_name == 'test'
&& resource.pod_name =~ 'server.*')
&& (metric.volume_name =~ 'dat.*')
| align mean_aligner()
| window 10m
| condition value.utilization > 0.001 '10^2.%'
`,
Trigger: &monitoring.Trigger{
Count: 1,
},
}
condition := monitoring.Condition{
DisplayName: "MQL-based Condition",
ConditionMonitoringQueryLanguage: mqlCondition,
}
alertpolicy := &monitoring.AlertPolicy{
DisplayName: "Prakash1",
Combiner: "OR",
Conditions: []*monitoring.Condition{&condition},
NotificationChannels: []string{"projects/abc-app/notificationChannels/16000000099515524778"},
}
p, err := service.Projects.AlertPolicies.Create("projects/abc-app", alertpolicy).Context(context.Background()).Do()
if err != nil {
log.Panicln(err)
return
}
当我同时创建两个或多个警报策略时,我收到以下错误:
"googleapi: Error 409: Too many concurrent edits to the project configuration. Please try again., aborted"
你能告诉我如何解决这个错误吗?
拉丁的传说
相关分类