Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes Hpa不获取现有自定义度量?_Kubernetes_Monitoring_Grafana_Prometheus_Autoscaling - Fatal编程技术网

Kubernetes Hpa不获取现有自定义度量?

Kubernetes Hpa不获取现有自定义度量?,kubernetes,monitoring,grafana,prometheus,autoscaling,Kubernetes,Monitoring,Grafana,Prometheus,Autoscaling,我正在使用mongodb exporter通过prometheus存储/查询指标。我已经建立了一个定制的度量服务器并存储了相应的值 这是普罗米修斯出口商与定制公制服务器兼容的证据 查询: kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/*/mongodb_mongod_wiredtiger_cache_bytes" {"kind":"MetricValueList","apiVe

我正在使用
mongodb exporter
通过
prometheus
存储/查询指标。我已经建立了一个定制的度量服务器并存储了相应的值

这是普罗米修斯出口商与定制公制服务器兼容的证据

查询:

kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/*/mongodb_mongod_wiredtiger_cache_bytes"
{"kind":"MetricValueList","apiVersion":"custom.metrics.k8s.io/v1beta1","metadata":{"selfLink":"/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/%2A/mongodb_mongod_wiredtiger_cache_bytes"},"items":[{"describedObject":{"kind":"Pod","namespace":"monitoring","name":"mongo-exporter-2-prometheus-mongodb-exporter-68f95fd65d-dvptr","apiVersion":"/v1"},"metricName":"mongodb_mongod_wiredtiger_cache_bytes","timestamp":"TTTTT","value":"0"}]}
结果:

kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/*/mongodb_mongod_wiredtiger_cache_bytes"
{"kind":"MetricValueList","apiVersion":"custom.metrics.k8s.io/v1beta1","metadata":{"selfLink":"/apis/custom.metrics.k8s.io/v1beta1/namespaces/monitoring/pods/%2A/mongodb_mongod_wiredtiger_cache_bytes"},"items":[{"describedObject":{"kind":"Pod","namespace":"monitoring","name":"mongo-exporter-2-prometheus-mongodb-exporter-68f95fd65d-dvptr","apiVersion":"/v1"},"metricName":"mongodb_mongod_wiredtiger_cache_bytes","timestamp":"TTTTT","value":"0"}]}
在我的情况下,当我从mongo exporter为此自定义指标创建hpa时,hpa会将此错误返回给我:

failed to get mongodb_mongod_wiredtiger_cache_bytes utilization: unable to get metrics for resource mongodb_mongod_wiredtiger_cache_bytes: no metrics returned from resource metrics API
我的案子的主要问题是什么?我已经检查了所有配置,流程看起来很好,但哪里是我的错误

帮助


谢谢:)

在您写的评论中,您已经启用了
外部.metrics
,但在最初的问题中,您对
自定义.metrics

简言之:

  • 指标
    仅支持CPU或内存等基本指标
  • custom.metrics
    允许您将基本度量扩展到所有Kubernetes对象(http_请求、POD数量等)
  • external.metrics
    允许收集非Kubernetes对象的指标:
外部指标允许您根据任何 监控系统中可用的度量。只需提供一个指标 使用名称和选择器块,如上所述,并使用外部度量 类型而不是对象

有关详细说明,请查看

Minikube

要验证是否启用了
custom.metrics
,您需要执行下面的命令,并检查是否可以看到任何
metrics服务器…
pod

$ kubectl get pods -n kube-system
...
metrics-server-587f876775-9qrtc    1/1     Running   4          5d1h
第二种方法是检查
minikube
是否通过

$ minikube addons list
...
- metrics-server: enabled
如果它被禁用,只需执行

$ sudo minikube addons enable metrics-server
✅  metrics-server was successfully enabled
GKE

目前,GKE的
heapster
metrics server
默认打开,但
自定义。默认情况下不支持度量。
您必须安装
prometheus适配器
stackdriver

Kubeadm

Kubeadm在开始时不包括
heapster
metrics server
。为了便于安装,您可以使用

稍后您必须安装普罗米修斯适配器

应用自定义的度量标准

这与
Minikube
Kubeadm
GKE
相同

应用
custom.metrics
的最简单方法是通过
Helm
安装

安装舵后,您将能够看到注意事项:

NOTES:
my-release-prometheus-adapter has been deployed.
In a few minutes you should be able to list metrics using the following command(s):

  kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1
作为附加信息,您可以使用
jq
获得更友好的输出


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

您能提供您的部署YAML吗?应用程序的部署YAML或其他与prometheus或metric server相关的组件的部署YAML?YAML的数量:1。mongodb出口商,2。普罗米修斯出口商,3。HPA。你是用一些教程创建的吗?您能否提供部署所有内容的步骤。您好@PjoterS我已通过启用外部度量api服务器处理了此问题。如果您找到了解决方案,请将您所做的作为回答并接受。对于可能有类似问题的人来说,这将更加明显。