我已经在 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}'