Google cloud platform 使用Stackdriver资源组';GCP部署管理器配置中的s ID
我正在尝试使用部署管理器配置创建Stackdriver。相同的配置首先创建和,然后基于以下内容创建策略:Google cloud platform 使用Stackdriver资源组';GCP部署管理器配置中的s ID,google-cloud-platform,stackdriver,google-cloud-stackdriver,google-deployment-manager,Google Cloud Platform,Stackdriver,Google Cloud Stackdriver,Google Deployment Manager,我正在尝试使用部署管理器配置创建Stackdriver。相同的配置首先创建和,然后基于以下内容创建策略: resources: - name: test-group type: gcp-types/monitoring-v3:projects.groups properties: displayName: A test group filter: >- resource.metadata.cloud_account="aproject-id" AND
resources:
- name: test-group
type: gcp-types/monitoring-v3:projects.groups
properties:
displayName: A test group
filter: >-
resource.metadata.cloud_account="aproject-id" AND
resource.type="gce_instance" AND
resource.metadata.tag."managed"="yes"
- name: test-email-notification
type: gcp-types/monitoring-v3:projects.notificationChannels
properties:
displayName: A test email channel
type: email
labels:
email_address: incidents@example.com
- name: test-alert-policy
type: gcp-types/monitoring-v3:projects.alertPolicies
properties:
enabled: true
displayName: A test alert policy
documentation:
mimeType: text/markdown
content: "Test incident"
notificationChannels:
- $(ref.test-email-notification.name)
combiner: OR
conditions:
- conditionAbsent:
aggregations:
- alignmentPeriod: 60s
perSeriesAligner: ALIGN_RATE
duration: 300s
filter: metric.type="compute.googleapis.com/instance/uptime" group.id="$(ref.test-group.id)"
trigger:
count: 1
displayName: The instance is down
策略的唯一条件具有基于资源组的筛选器,即只有组的成员才能触发此警报
我正在尝试使用对组ID的引用,但无效-“引用“ID”无效,原因:引用架构上不存在字段“ID”。
另外,当我尝试使用$(ref.test-group.selfLink)
时,我得到引用“selfLink”无效,原因是:引用架构上不存在字段“selfLink”。
我可以获取组的名称(例如,“projects/aproject id/groups/3691870619975147604”),但仅接受(例如,仅接受“3691870619975147604”部分):
“{”ResourceType:“gcp类型/monitoring-v3:projects.AlertPolicys”,“ResourceErrorCode:“400”,“ResourceErrorMessage:{”code:400,“message:“字段”
警报\u策略.conditions[0]。condition\u缺席.filter的\“metric.type=\“compute.googleapis.com/instance/uptime”值无效
group.id=\“projects/aprojectid/groups/3691870619975147604\”:
必须在筛选器中指定对“resource.type”的限制;请参阅https://cloud.google.com/monitoring/api/resources\"
有关可用资源类型的列表,请参见“,”状态“:”无效的参数“,”状态消息“:”错误
请求”,“请求路径”:https://monitoring.googleapis.com/v3/projects/aproject-id/alertPolicies“,“httpMethod”:“POST”}”
尝试用以下内容替换您的警报策略:
- name: test-alert-policy
type: gcp-types/monitoring-v3:projects.alertPolicies
properties:
enabled: true
displayName: A test alert policy
documentation:
mimeType: text/markdown
content: "Test incident"
notificationChannels:
- $(ref.test-email-notification.name)
combiner: OR
conditions:
- conditionAbsent:
aggregations:
- alignmentPeriod: 60s
perSeriesAligner: ALIGN_RATE
duration: 300s
filter: metric.type="compute.googleapis.com/instance/uptime" $(ref.test-group.filter)
trigger:
count: 1
displayName: The instance is down
metadata:
dependsOn:
- test-group
这增加了1)使用子句对测试组
的显式依赖关系,以及2)对度量过滤器的$(ref.test-group.filter)
的显式依赖关系,因此它虽然没有严格链接到测试组
,但最终包含与测试组
相同的所有资源
由于部署管理器资源是并行运行的,因此有必要使用
dependsOn
,以确保在尝试创建test alert policy
之前实例化test group
;显然,部署管理器不太聪明,无法仅凭引用来解释这一点。您确定要使用组ID吗?t该错误抱怨对resource.type没有限制(必须在筛选器中指定对“resource.type”的限制)。你说得对,我的错-正如下面的回答所示,当resource.type=“gce\u实例“
已添加到条件的筛选器中。向前一步-现在部署成功,但创建的策略仍被破坏,即筛选器包含group.id=“projects/aproject id/groups/5310387734849288536”
,并且不会生成警报。对于相同的条件,工作策略的条件筛选器包含group.id=“5310387734849288536”
。太好了,开始吧!隐马尔可夫模型。。。一种解决方法是将部署管理器配置中的策略筛选器设置为metric.type=“compute.googleapis.com/instance/uptime”$(ref.test-group.filter)
;现在,创建的策略虽然没有严格链接到组,但最终包含与组相同的所有资源。也就是说,已实现策略的筛选器类似于metric.type=“compute.googleapis.com/instance/uptime”resource.metadata.cloud\u account=“…”和resource.type=“gce\u instance”和resource.metadata.tag。“managed”=“yes”
。这起到了作用-策略的筛选器复制了组的筛选器。这不是我想要的(将政策与团体挂钩),但它实现了同样的目标——“干涸”。请把这个加在你的答案上,我会接受的。