首页 新闻 会员 周边

通过 custom metrics api 获取 http_requests 的问题

0
悬赏园豆:30 [已解决问题] 解决于 2020-01-18 22:53

基于 k8s-prometheus-adapter 的 custom metrics api 部署好了,请求下面的 url 有正常响应

kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/" | jq .

但通过下面的命令获取 http_requests 指标却出错:

kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/production/pods/*/http_requests" | jq .
Error from server (NotFound): the server could not find the metric http_requests for pods

请问如何解决?

k8s
问题补充:

通过 prometheus 所在的命名空间 monitoring 可以获取到 prometheus_http_requests 指标数据

kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/*/prometheus_http_requests | jq .

但换成应用在命名空间 production 获取不到 prometheus_http_requests 指标数据,items 为空。

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

通过 kubectl logs kube-controller-manager-k8s-master1 -n kube-system | tail 查看 controller manager 的日志,发现下面的错误:

unable to get metric http_requests: unable to fetch metrics from custom metrics API: the server could not find the metric http_requests for pods

dudu的主页 dudu | 高人七级 | 园豆:30979
提问于:2020-01-14 16:39

stackoverflow 上的相同问题(未解决):Prometheus' http_request custom-metric not working in Kubernetes

dudu 4年前

访问 prometheus 控制台查询 prometheus_http_requests_total 指标发现的确只有 monitoring 命名空间下的 pod

dudu 4年前
< >
分享
最佳答案
0
dudu | 高人七级 |园豆:30979 | 2020-01-18 22:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册