使用Prometheus“target relabeling”来提取cAdvisor的Docker镜像名称,而不需要标记

我使用Prometheus和cAdvisor一起监视我的环境。

现在,我试图使用Prometheus的“target relbeling”,并创build一个标签,它的值是Docker容器的图像名称,没有标签。 它是基于最初刮过的image标签。

由于某种原因,它不起作用,在debugging日志级别上运行时显示没有错误。 我可以看到从cAdvisor刮取的指标(例如container_last_seen ),但是我新创build的标签不在那里。

我的工作configuration:

  - job_name: "cadvisor" scrape_interval: "5s" dns_sd_configs: - names: ['cadvisor.marathon.mesos'] relabel_configs: - source_labels: ['image'] # [REGISTRYHOST/][USERNAME/]NAME[:TAG] regex: '([^/]+/)?([^/]+/)?([^:]+)(:.+)?' target_label: 'image_tagless' replacement: '${1}${2}${3}' 

我的标签 – image_tagless – 缺less指标。

任何帮助将非常感激。

图片标签不是目标标签,它是在度量标准上。 因此,您应该使用metric_relabel_configs而不是relabel_configs

我的一个标签的生命博客解释了这是如何工作的。