简体   繁体   English

Prometheus 适配器返回空的自定义指标

[英]Prometheus adapter return empty custom metrics

Having configured metric rule in the prometheus-adapter, I can see resources as follows.在 prometheus-adapter 中配置了 metric 规则后,我可以看到如下资源。

kubectl get --raw="/apis/custom.metrics.k8s.io/v1beta1" | jq .
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "custom.metrics.k8s.io/v1beta1",
  "resources": [
    {
      "name": "pods/istio_ai_retry_per_second",
      "singularName": "",
      "namespaced": true,
      "kind": "MetricValueList",
      "verbs": [
        "get"
      ]
    },
    {
      "name": "namespaces/istio_ai_retry_per_second",
      "singularName": "",
      "namespaced": false,
      "kind": "MetricValueList",
      "verbs": [
        "get"
      ]
    }
  ]
}

But when I try to get metrics values.但是当我尝试获取指标值时。 The items are empty.物品为空。

kubectl get --raw="/apis/custom.metrics.k8s.io/v1beta1/namespaces/aiservice-test/pods/*/istio_ai_retry_per_second" | jq .
{
  "kind": "MetricValueList",
  "apiVersion": "custom.metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/aiservice-test/pods/%2A/istio_ai_retry_per_second"
  },
  "items": []
}

This is the rule,这是规矩,

 10   - seriesQuery: 'istio_ai_retry_count{destination_workload="cpuporncheck-default-k8s",reporter="destination"}'
 11     resources:
 12       overrides:
 13         destination_workload: {resource: "pod"}
 14         destination_workload_namespace: {resource: "namespace"}
 15     name:
 16       matches: "^(.*)_count"
 17       as: "${1}_per_second"
 18     metricsQuery: "sum(rate(istio_ai_retry_count{<<.LabelMatchers>>}[2m])) by (<<.GroupBy>>)"

Can anyone help me to check what's wrong with it?任何人都可以帮我检查它有什么问题吗?

OP confirmed that the problem was with rules. OP 确认问题出在规则上。

Changeing pod to deployment and api access path to sth like:pod更改为deployment和 api 访问路径,例如:

 /apis/custom.metrics.k8s.io/v1beta1/namespaces/{namespace_name}/deployment/{deployment_name}/{metric}

resolved the issue.解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM