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或内存等基本指标指标
允许您将基本度量扩展到所有Kubernetes对象(http_请求、POD数量等)custom.metrics
允许收集非Kubernetes对象的指标:external.metrics
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服务器处理了此问题。如果您找到了解决方案,请将您所做的作为回答并接受。对于可能有类似问题的人来说,这将更加明显。