我已经使用以下命令安装了 promethus 适配器:
helm install prometheus-adapter prometheus-community/prometheus-adapter --namespace monitoring
-f adapter_custom_values.yaml
但是,当使用 kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 检查时,我没有看到任何指标被注册。这是 adapter_custom_values.yaml 文件的预览:
prometheus:
# Run `kubectl get svc -n namespace` to get the url of Prometheus
url: http://prometheus-kube-prometheus-prometheus.monitoring.svc
port: 9090
logLevel: 10
replicas: 1
rules:
# Whether to enable the default rules
default: false
# Add custom metrics API here
custom:
# plex_queue_size API
- seriesQuery: 'plex_queue_size'
resources:
overrides:
namespace: {resource: "namespace"}
pod: {resource: "pod"}
name:
matches: ^(.*)
as: "plex_queue_size"
metricsQuery: <<.Series>>{<<.LabelMatchers>>}
但是,当使用命令kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1检查自定义指标 api 时,我得到空响应:
{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "custom.metrics.k8s.io/v1beta1",
"resources": []
}
从适配器日志中,我可以看到对 prometheus 的请求是成功的,但是 Responsde Body 中的数据是空的:
GET http://prometheus-kube-prometheus-prometheus.monitoring.svc:9090/api/v1/series?match%5B%5D=plex_queue_size&start=1640091045.342 200 OK
Response Body: {"status":"success","data":[]}
Set available metric list from Prometheus to: [[]] .
Kube-prometheus-stack 也与 helm 一起安装。
我的问题是为什么自定义指标没有在自定义指标 API 中注册?任何帮助,将不胜感激。