[英]How to scrape metrics-server to prometheus outside kubernetes cluster
我已经安装了 kubernetes metrics-server https://github.com/kubernetes-sigs/metrics-server它工作正常,我可以使用“kubectl top pods”和“kubectl top nodes”,现在我想抓取指标来prometheus在Grafana上显示的kubernetes集群之外,我尝试过的是
我应该怎么办?
试试这些,让我知道。
1.首先,您应该运行 kube-state-metrics 来收集所有 kubernetes 指标。
2.在 kube-state-metrics 上使用 pod 注释,公开指标,例如
prometheus.io/scrape: 'true'
prometheus.io/port: 'port'
prometheus.io/path: '/metrics'
prometheus.io/scheme: 'http'
这应该从 pod 级别公开您的指标。 要检查这一点,您可以执行到 pod 并在端口上执行 curl 请求,然后是路径
3.现在运行一个prometheus代理,它可以从这个端口抓取指标并将其发送到后端数据库服务器
4.在你的grafana代理中配置prometheus ds,应该完成
您可以使用helm安装kube-prometheus-stack 。
它将安装Node Exporter
、 kube-state-metrics
和prometheus operator
以及其他依赖项,以允许您监控集群。
您可以使用以下方法安装它:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add stable https://charts.helm.sh/stable
helm repo update
helm install [RELEASE_NAME] prometheus-community/kube-prometheus-stack
安装后,您可以访问您的 grafana URL 并配置仪表板。
您可以在 grafana 中添加 prometheus 作为数据源 [ Configuration
-> Data Source
](prometheus URL 应默认设置)并导入kubernetes 仪表板以向您显示有关在 Z3013668317 节点上运行的容器的摘要指标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.