我有一个 GKE 集群,我想跟踪请求的总内存与可分配的总内存之间的比率。我能够使用在 Google Cloud Monitoring 中创建图表
metric.type="kubernetes.io/container/memory/request_bytes" resource.type="k8s_container"
和
metric.type="kubernetes.io/node/memory/allocatable_bytes" resource.type="k8s_node"
两者都crossSeriesReducer
设置为REDUCE_SUM
以获得整个集群的总和。
然后,当我尝试使用两者的比率(如下)设置警报策略(使用云监控 api)时,我收到此错误
ERROR: (gcloud.alpha.monitoring.policies.create) INVALID_ARGUMENT: The numerator and denominator must have the same resource type.
它不喜欢第一个指标是 ak8s_container
而第二个指标是 ak8s_node
我可以使用不同的指标或某种解决方法来提醒 Google Cloud Monitoring 中的内存请求/可分配比率吗?
编辑:
这是完整的请求和响应
$ gcloud alpha monitoring policies create --policy-from-file=policy.json
ERROR: (gcloud.alpha.monitoring.policies.create) INVALID_ARGUMENT: The numerator and denominator must have the same resource type.
$ cat policy.json
{
"displayName": "Cluster Memory",
"enabled": true,
"combiner": "OR",
"conditions": [
{
"displayName": "Ratio: Memory Requests / Memory Allocatable",
"conditionThreshold": {
"filter": "metric.type=\"kubernetes.io/container/memory/request_bytes\" resource.type=\"k8s_container\"",
"aggregations": [
{
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [
],
"perSeriesAligner": "ALIGN_MEAN"
}
],
"denominatorFilter": "metric.type=\"kubernetes.io/node/memory/allocatable_bytes\" resource.type=\"k8s_node\"",
"denominatorAggregations": [
{
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_SUM",
"groupByFields": [
],
"perSeriesAligner": "ALIGN_MEAN",
}
],
"comparison": "COMPARISON_GT",
"thresholdValue": 0.8,
"duration": "60s",
"trigger": {
"count": 1
}
}
}
]
}