【发布时间】:2021-06-23 02:08:30
【问题描述】:
我已经成功部署
- prometheus 通过 helm 图表 kube-prometheus-stack (https://prometheus-community.github.io/helm-charts)
- prometheus-adapter via helm chart prometheus-adapter (https://prometheus-community.github.io/helm-charts)
使用带有轻微定制的默认配置。
我可以访问 prometheus、grafana 和 alertmanager,查询指标并查看精美的图表。
但是 prometheus-adapter 在启动时一直抱怨它无法访问/发现指标:
I0326 08:16:52.266095 1 adapter.go:98] successfully using in-cluster auth
I0326 08:16:52.330094 1 dynamic_serving_content.go:111] Loaded a new cert/key pair for "serving-cert::/var/run/serving-cert/tls.crt::/var/run/serving-cert/tls.key"
E0326 08:16:52.334710 1 provider.go:227] unable to update list of all metrics: unable to fetch metrics for query "{namespace!=\"\",__name__!~\"^container_.*\"}": bad_response: unknown response code 404
我在 prometheus-adapter Deployment 命令行参数中尝试了各种 prometheus URL,但问题或多或少是一样的。
例如我试过的一些网址是
--prometheus-url=http://prometheus-operated.prom.svc:9090
--prometheus-url=http://prometheus-kube-prometheus-prometheus.prom.svc.cluster.local:9090
有以下服务/pods在运行:
$ kubectl -n prom get pods
NAME READY STATUS RESTARTS AGE
alertmanager-prometheus-kube-prometheus-alertmanager-0 2/2 Running 0 16h
prometheus-adapter-76fcc79b7b-7xvrm 1/1 Running 0 10m
prometheus-grafana-559b79b564-bh85n 2/2 Running 0 16h
prometheus-kube-prometheus-operator-8556f58759-kl84l 1/1 Running 0 16h
prometheus-kube-state-metrics-6bfcd6f648-ms459 1/1 Running 0 16h
prometheus-prometheus-kube-prometheus-prometheus-0 2/2 Running 1 16h
prometheus-prometheus-node-exporter-2x6mt 1/1 Running 0 16h
prometheus-prometheus-node-exporter-bns9n 1/1 Running 0 16h
prometheus-prometheus-node-exporter-sbcjb 1/1 Running 0 16h
$ kubectl -n prom get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
alertmanager-operated ClusterIP None <none> 9093/TCP,9094/TCP,9094/UDP 16h
prometheus-adapter ClusterIP 10.0.144.45 <none> 443/TCP 16h
prometheus-grafana ClusterIP 10.0.94.160 <none> 80/TCP 16h
prometheus-kube-prometheus-alertmanager ClusterIP 10.0.0.135 <none> 9093/TCP 16h
prometheus-kube-prometheus-operator ClusterIP 10.0.170.205 <none> 443/TCP 16h
prometheus-kube-prometheus-prometheus ClusterIP 10.0.250.223 <none> 9090/TCP 16h
prometheus-kube-state-metrics ClusterIP 10.0.135.215 <none> 8080/TCP 16h
prometheus-operated ClusterIP None <none> 9090/TCP 16h
prometheus-prometheus-node-exporter ClusterIP 10.0.70.247 <none> 9100/TCP 16h
kubectl -n kube-system get deployment/metrics-server
NAME READY UP-TO-DATE AVAILABLE AGE
metrics-server 1/1 1 1 15d
使用以下值部署 Prometheus-adapter helm chart:
prometheus:
url: http://prometheus-kube-prometheus-prometheus.prom.svc.cluster.local
certManager:
enabled: true
我的设置中 prometheus-adapter 的 --prometheus-url 的正确值是多少?
【问题讨论】:
-
后续问题是我看不到要用于 HPA 的自定义指标。例如。
kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1导致空指标:{"kind":"APIResourceList","apiVersion":"v1","groupVersion":"custom.metrics.k8s.io/v1beta1","resources":[]}。 -
您的网址似乎是正确的。我没有部署
prometheus-adapter,但我可以从 pod 内卷曲 URL(格式与您的格式相似)。你能试试这个吗?以排除集群 dns 的任何问题。 -
从 POD 中(在不同的命名空间中)我可以运行
wget -O - http://prometheus-kube-prometheus-prometheus.prom.svc.cluster.local:9090并获得包含<title>Prometheus Time Series Collection and Processing Server</title>的 HTML 响应。 -
看起来差不多。您可以编辑您的问题并分享
prometheus-adapter的值文件吗?至于 HPA 的指标,首先要确认您已经部署了指标服务器吗? -
此外,我尝试查询普罗米修斯 UI 使用的相同配置指标(如果这实际上是一个有效的 URL)。例如。执行
wget -O - "http://prometheus-kube-prometheus-prometheus.prom.svc.cluster.local:9090/api/v1/query?query=%7Bnamespace%21%3D%22%22%2C__name__%21%7E%22%5Econtainer_.*%22%7D&time=1616751935.431"会产生相同的 404。
标签: kubernetes prometheus