Kubernetes 普罗米修斯从部署在k8s上的api中获取吊舱名称
我在k8s上部署了一个api,这个部署包含多个pod,并且(例如)每个pod都有一个度量,显示调用“login”方法的次数 在抓取数据时,我想知道我当前看到的数据来自哪个pod 我的普罗米修斯外形像Kubernetes 普罗米修斯从部署在k8s上的api中获取吊舱名称,kubernetes,devops,monitoring,prometheus,Kubernetes,Devops,Monitoring,Prometheus,我在k8s上部署了一个api,这个部署包含多个pod,并且(例如)每个pod都有一个度量,显示调用“login”方法的次数 在抓取数据时,我想知道我当前看到的数据来自哪个pod 我的普罗米修斯外形像 scrape_configs: - job_name: 'my-api' scheme: https static_configs: - targets: ['not-real-api-link.com:443'] label
scrape_configs:
- job_name: 'my-api'
scheme: https
static_configs:
- targets: ['not-real-api-link.com:443']
labels:
group: 'dev'
login{group="dev",instance="not-real-api-link.com:443",job="my-api", k8s_pod_name="not-real-api-4l8o15s16t-tavd"}
使用此配置,刮取一个值,如:
login{group="dev",instance="not-real-api-link.com:443",job="my-api"}
但我需要像这样的东西
scrape_configs:
- job_name: 'my-api'
scheme: https
static_configs:
- targets: ['not-real-api-link.com:443']
labels:
group: 'dev'
login{group="dev",instance="not-real-api-link.com:443",job="my-api", k8s_pod_name="not-real-api-4l8o15s16t-tavd"}
环顾四周,我发现应该是这样的:
scrape_configs:
- job_name: 'my-api'
scheme: https
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: k8s_pod_name
static_configs:
- targets: ['not-real-api-link.com:443']
labels:
group: 'dev'
但它不起作用。我错过了什么