gcloud alpha 监控策略创建 --policy-from-file 在过滤器中抛出错误 "must specify a restriction on "resource.type"
gcloud alpha monitoring policies create --policy-from-file throws error "must specify a restriction on "resource.type" in the filter"
我使用云控制台创建了几个警报策略,但在导出它们并更改名称(通过下载 JSON 或 gcloud CLI)后,我无法将它们导入回来。
详情如下:
有效负载(名称字段在导出后被删除):
{
"displayName": "somename",
"conditions": [
{
"displayName": "somename",
"conditionAbsent": {
"aggregations": [
{
"alignmentPeriod": "300s",
"crossSeriesReducer": "REDUCE_MEAN",
"perSeriesAligner": "ALIGN_DELTA"
}
],
"duration": "300s",
"filter": "metric.type=\"logging.googleapis.com/user/some-metric\""
}
}
],
"combiner": "OR",
"enabled": true,
"notificationChannels": [
"projects/my-prod-dod/notificationChannels/1962880049684990238",
"projects/my-prod-dod/notificationChannels/9131919367771592634"
]
}
命令:
gcloud alpha monitoring policies create --policy-from-file alert.json
错误:
Field alert_policy.conditions[0].condition_absent.filter had an invalid value of "metric.type="logging.googleapis.com/user/some-metric"": must specify a restriction on "resource.type" in the filter
指标类型为:
警报政策截图:
像下面这样添加额外的过滤器解决了问题
"filter": "metric.type=\"logging.googleapis.com/user/celery-person\" resource.type=\"k8s_container\"",
类似问题:
我使用云控制台创建了几个警报策略,但在导出它们并更改名称(通过下载 JSON 或 gcloud CLI)后,我无法将它们导入回来。
详情如下:
有效负载(名称字段在导出后被删除):
{
"displayName": "somename",
"conditions": [
{
"displayName": "somename",
"conditionAbsent": {
"aggregations": [
{
"alignmentPeriod": "300s",
"crossSeriesReducer": "REDUCE_MEAN",
"perSeriesAligner": "ALIGN_DELTA"
}
],
"duration": "300s",
"filter": "metric.type=\"logging.googleapis.com/user/some-metric\""
}
}
],
"combiner": "OR",
"enabled": true,
"notificationChannels": [
"projects/my-prod-dod/notificationChannels/1962880049684990238",
"projects/my-prod-dod/notificationChannels/9131919367771592634"
]
}
命令:
gcloud alpha monitoring policies create --policy-from-file alert.json
错误:
Field alert_policy.conditions[0].condition_absent.filter had an invalid value of "metric.type="logging.googleapis.com/user/some-metric"": must specify a restriction on "resource.type" in the filter
指标类型为:
警报政策截图:
像下面这样添加额外的过滤器解决了问题
"filter": "metric.type=\"logging.googleapis.com/user/celery-person\" resource.type=\"k8s_container\"",
类似问题: