![Prometheus 服务器未显示 apiserver 节点的 Cadvisor 指标](https://linux22.com/image/1208403/Prometheus%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%9C%AA%E6%98%BE%E7%A4%BA%20apiserver%20%E8%8A%82%E7%82%B9%E7%9A%84%20Cadvisor%20%E6%8C%87%E6%A0%87.png)
我已经在 Microk8s 上部署了 prometheus helm 图表,一切运行正常。我遇到的唯一问题是它似乎没有轮询带有 apiserver 的领导节点的指标。我的抓取配置如下,主要基于 Grafana 在其文档中提供的示例,因此不能 100% 确定我在这里做什么。如果我转到 Prometheus 并运行查询(例如 cadvisor_version_info),它将仅显示我的仅工作节点(由实例标识),但不显示包含 apiserver 的领导节点。我该如何调整它,以便它也从带有 apiserver 的领导节点抓取指标?
- job_name: kubernetes-nodes-cadvisor
scrape_interval: 1m
scrape_timeout: 15s
scheme: https # remove if you want to scrape metrics on insecure port
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- target_label: __address__
replacement: kubernetes.default.svc:443
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /api/v1/nodes/${1}/proxy/metrics/cadvisor
metric_relabel_configs:
- action: replace
source_labels: [id]
regex: '^/machine\.slice/machine-rkt\\x2d([^\\]+)\\.+/([^/]+)\.service$'
target_label: rkt_container_name
replacement: '${2}-${1}'
- action: replace
source_labels: [id]
regex: '^/system\.slice/(.+)\.service$'
target_label: systemd_service_name
replacement: '${1}'