【发布时间】:2021-08-13 13:46:28
【问题描述】:
"如果一个容器没有指定端口,则每个容器都有一个无端口目标 创建容器是为了通过重新标记手动添加端口。”
但是,在我的设置中,带有 containerports 的 pod 的 address 标签已按预期转换,但那些没有 containerports 的 pod 被保留为“无端口”。这是常见/可接受的行为,还是我应该改变一些东西才能将 __meta_kubernetes_pod_annotation_prometheus_io_port 作为地址端口?谢谢!
additionalScrapeConfigs:
- job_name: 'perpod-metricsscrape'
scrape_interval: 5s
metrics_path: /metrics
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_scrape ]
action: keep
regex: true
- source_labels: [ __meta_kubernetes_pod_annotation_prometheus_io_path ]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [ __address__, __meta_kubernetes_pod_annotation_prometheus_io_port ]
action: replace
regex: (.+)(?::\d+);(\d+)
replacement: ${1}:${2}
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
顺便说一句,我从大多数漂浮的示例中稍微更改了正则表达式,认为它们与没有端口的地址不匹配(与前面提到的无容器 pod 的情况一样) - 在重新标记之前:_ _ 地址 _ ="1.2.3.4"
【问题讨论】:
标签: kubernetes prometheus