【发布时间】:2020-08-31 14:33:19
【问题描述】:
我希望 Prometheus 只抓取我的 Kubernetes 集群中带有特定注释的 pod。因此,在作业配置中,我想按照此处的建议使用__meta_kubernetes_pod_annotationpresent_<annotationname> : true - 针对 Prometheus 的每个 Kubernetes SD 配置的 https://prometheus.io/docs/prometheus/latest/configuration/configuration/#pod。
问题是,我找不到任何相同的例子:(
一位同事建议-
- job_name: 'k8sPodScrape'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: ['__meta_kubernetes_pod_annotationpresent_my_custom_annotation']
action: 'keep'
regex: 'true'
但我不确定它是否有效以及如何运作?任何指针都会有很大帮助。
【问题讨论】:
标签: prometheus