如何在 Kubernetes Dashboard 中获取 Prometheus 数据

How to get Prometheus data in Kubernetes Dashboard

我们正在使用 Prometheus 来监控我们的 kubernetes。我正在浏览 kubernetes 仪表板代码。 API 在那里可以访问 heapster(即将删除)指标。我想知道,有什么办法可以将 prometheus 数据集成到 kubernetes dashboard 中吗?我在想我们需要编写新的 API 来访问普罗米修斯数据,并且 return 它们的格式与 kubernetes 仪表板期望的格式相同。(即 heapster API 的格式)。

如果有任何其他更好的集成方法,请提出建议。

PS:对托管 grafana 仪表板以访问 premethus 数据不感兴趣。

我认为您需要为 Prometheus 数据编写自己的解析器才能将其与 kubernetes 仪表板一起使用,但是 metrics-server, I guess it is a solution you are looking for, but please also check rancher

目前答案是

GitHub will dashboar support prometheus?.

已经有人问过这个问题

@floreks 写道:

It was planned at some point, but we do not have enough devs and time to work on such integrations right now. It will be added at some point for sure. I'd love to only use kubernetes metrics API and get rid of heapster/prometheus hard dependencies. I'll have to investigate if this is possible.

您需要一种以某种方式存储值的方法,因为现在您获得的是一次当前值:

http://10.110.17.88:8080/apis/metrics.k8s.io/v1beta1/nodes/node2 响应是:

{ "kind": "NodeMetrics", "apiVersion": "metrics.k8s.io/v1beta1", "metadata": { "name": "node2", "selfLink": "/apis/metrics.k8s.io/v1beta1/nodes/node2", "creationTimestamp": "2017-11-10T09:57:48Z" }, "timestamp": "2017-11-10T09:57:00Z", "window": "1m0s", "usage": { "cpu": "185m", "memory": "2471876Ki" } }