mko*_*mko 5 kubernetes prometheus
我已经成功部署了
使用默认配置并进行少量定制。
我可以访问 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
Run Code Online (Sandbox Code Playgroud)
我已经在 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
Run Code Online (Sandbox Code Playgroud)
有以下服务/pod正在运行:
$ 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
Run Code Online (Sandbox Code Playgroud)
Prometheus 适配器 helm 图表使用以下值进行部署:
prometheus:
url: http://prometheus-kube-prometheus-prometheus.prom.svc.cluster.local
certManager:
enabled: true
Run Code Online (Sandbox Code Playgroud)
我的设置中prometheus-adapter--prometheus-url
的正确值是多少?
该问题与用于通过 Ingress 暴露 prometheus 的附加路径有关。
/monitoring/prometheus/
我在入口配置中使用了额外的路径前缀。
解决方案是也告诉 prometheus-adapter,prometheus 是可访问的,包括。该路径前缀。因此,以下内容使 prometheus-adapter 满意:
--prometheus-url=http://prometheus-kube-prometheus-prometheus.prom.svc.cluster.local:9090/monitoring/prometheus/
Run Code Online (Sandbox Code Playgroud)
现在我可以在执行时看到自定义指标
kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1
Run Code Online (Sandbox Code Playgroud)
感谢“rock'n rolla”提供一些提示!
归档时间: |
|
查看次数: |
8811 次 |
最近记录: |